I dont usually use MySQL workbench, I am trying to create a table with a text column by choosing TEXT(), however I am not sure what value I should put in between the '()'. If I leave it blank it gives me the error:
The given data type TEXT() contains errors and cannot be accepted. The previous value is kept instead.
I can put a number inside the parentheses but I wanted to know how it affects the column.
I could not find any answers online. I know how it affects things such as DATETIME() but not this data type.
The actual TEXT column type is of four types-TINYTEXT, TEXT, MEDIUMTEXT and LONGTEXT. The four TEXT types are very similar to each other; the only difference is the maximum amount of data each can store. The smallest TEXT type, TINYTEXT shares the same character length as VARCHAR.
ZF is for Zero Filled. Suppose, we have declared int(3) and you want to store 21, then zero filled would output the result 021.
Double-click the first entry in one of your columns and type the data to be added. After entering the necessary data, hit Enter on your keyboard. Double-click under that newly created row and create another. Once you add all of your data, click Apply to execute the SQL Script.
In TEXT(M) M is an optional length. From the docs:
An optional length M can be given for this type. If this is done, MySQL creates the column as the smallest TEXT type large enough to hold values M characters long.
So you can use it to specify the maximum number of characters you anticipate for the field.
If you omit the parens - just TEXT - it will default to 65,535. Otherwise, if you supply the parens and a value it will default to the appropriate text type (TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT).
See here for a comparison with VARCHAR. One difference is that you cannot directly index a TEXT field, it requires a prefix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With