Mysql – Text storage for thesql


So I want to create a command like first_name VARCHAR(30) NOT NULL, … however I want the database to hold more characters like a text storage type. How would I set up the command for the text type?

Best Answer

Just do

  first_name text

The ENGINE is InnoDB by default. Your default-character-set should be set to utf8mb4 changing that to the older utf8 is a very bad. Just leave well enough alone.

BTW, I fully agree with Rick James, you really don't want text here. The MySQL best practices would be something like varchar(255) which stores the column in-line. There are storage implications of using text on MySQL (though not in PostgreSQL). From the docs,

Each BLOB or TEXT value is represented internally by a separately allocated object. This is in contrast to all other data types, for which storage is allocated once per column when the table is opened.

They're also a byte bigger than varchar(255)

For more information see