MySQL TEXT or VARCHAR

六月ゝ 毕业季﹏ 提交于 2019-12-04 03:48:55

VARCHAR is probably preferable in your case from both the storage and performance perspective. View this oft-reposted article.

This is useful information; I think in general, the answer is the varchar is usually the better bet.

From the MySQL manual:

In most respects, you can regard a BLOB column as a VARBINARY column that can be as large as you like. Similarly, you can regard a TEXT column as a VARCHAR column. BLOB and TEXT differ from VARBINARY and VARCHAR in the following ways:

There is no trailing-space removal for BLOB and TEXT columns when values

are stored or retrieved. Before MySQL 5.0.3, this differs from VARBINARY and VARCHAR, for which trailing spaces are removed when values are stored.

On comparisons, TEXT is space extended to fit the compared object,

exactly like CHAR and VARCHAR.

For indexes on BLOB and TEXT columns, you must specify an index

prefix length. For CHAR and VARCHAR, a prefix length is optional. See Section 7.5.1, “Column Indexes”.

BLOB and TEXT columns cannot have DEFAULT values.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!