开发者

What's the maximum size of data is possible to insert for varchar(50);

I h开发者_高级运维ave to apply the restriction through the database that not more than 200kb of data can be inserted in the related field then what should be the varchar size.


If you want to store data larger than 64kb, you'll need to use the TEXT or BLOB column types, as mysql has a 64kb limit for VARCHAR types in general.

For columns that will only store less than 64kb per row, you can use a VARCHAR, but the number in the parenthesis must be the maximum number of characters the column can take. However, note even then that large text can still be better in a TEXT or BLOB column if you're using innodb, as innodb will store the contents of the TEXT/BLOB type away from the other columns, to avoid hurting performance on scans of the table.


you should be using varchar(8000) as max for non-unicode character data. the number in varchar represents bytes. You can specify a maximum of 8000 which does not exceed your 200kb limit. The storage size is the actual length of data entered + 2 bytes.

EDIT - Correction - From the comments below -

The effective maximum length of a VARCHAR in MySQL 5.0.3 and later is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used." so depending on what else is in the row, it might be smaller than that

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜