Reputation: 97
I want to create a table with
username TEXT (20 characters) .....
Is this possible? I can use that limit only with varchar
but I would like to use it with text, lontenxt
thank you
Upvotes: 0
Views: 1013
Reputation: 1271003
You can use varchar()
with a length:
username varchar(20)
You use text
specifically when you don't want to limit the length.
The more recent versions of MySQL also have check constraints. So you can also use such a constraint:
constraint chk_t_username_length check (char_length(username) <= 20)
Upvotes: 1