Why can't I set varchar to 1000 in length

If that matters, I also set it unique

The maximum value that I managed to set for varchar is 745 (it is also unique).

+3
source share
5 answers

Depends on the version of MySQL you are working with, up to 5.0.3 there was a 255 character limit for varchar:

Values ​​in VARCHAR columns: variable-length rows. The length can be set as a value from 0 to 255 to MySQL 5.0.3 and 0 to 65 535 in versions 5.0.3 and later.

From: http://dev.mysql.com/doc/refman/5.0/en/char.html

+4
source

Update:

, 1000 :

- 1000 . . 250 , 1024 .

, , .
varchar 1000 , .

, InnoDB, restrictions:

767 . . 12.1.8, " CREATE INDEX".


, , .

, , , MySQL (. 12.1.8, "CREATE INDEX Syntax" ). , , , , , , . . 7.5.3 " ".

, n , . , .

:

CREATE INDEX part_of_name ON customer (name(10));
+2

mysql?

5, newer long varchar

http://dev.mysql.com/doc/refman/5.0/en/char.html

VARCHAR: . 0 255 MySQL 5.0.3 0 65 535 5.0.3 . VARCHAR MySQL 5.0.3 (65 535 , ) .

+1

MySQL : http://dev.mysql.com/doc/refman/5.0/en/char.html

VARCHAR . 0 255 MySQL 5.0.3 0 65535 5.0.3 . VARCHAR MySQL 5.0.3 (65 535 , ) .

: 500 . ( http://bugs.mysql.com/bug.php?id=2130)

+1

The next step up in length is likely to be text, although, as far as I know, it has a really huge limitation on the length of the database, if any, so you will need to provide restrictions in the sql / backend application for programming the logic.

0
source

Source: https://habr.com/ru/post/1735452/


All Articles