0

In my Mysql DB I have a field which is used to store user-inputted text, and therefore set as Text and not varchar.

A user can input a maximum of 3000 characters which is then saved into the Text field.

So, should I give the Text field an length of 3000 in Mysql? Since thats the maximum characters a user can submit. More or less like length with varchar works.

Thanks in advance,

0

1 Answer 1

0

A MySQL text field can store a maximum of 65535 characters (using single-byte characters).

You don't need to specify a text field's length like you do for varchar.

Sign up to request clarification or add additional context in comments.

2 Comments

But in order to add a Index key to the text field. Do I have to set a length first? Coz right now I cant add a index key to the text field, or that might be just coz it is a text field.
TEXT columns can be indexed but a prefix length must be given. Example: CREATE UNIQUE INDEX index_name ON myfield (key(10)); This example indexes just the first 10 characters.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.