VARCHAR大小限制了吗? [英] Does VARCHAR size limit matter?

查看:92
本文介绍了VARCHAR大小限制了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

MySQL表中varchar长度的重要性

当使用VARCHAR(假设这是短字符串的正确数据类型)大小是否重要?如果我将它设置为20个字符,那么占用的空间要小于255个字符?

When using VARCHAR (assuming this is the correct data type for a short string) does the size matter? If I set it to 20 characters, will that take up less space or be faster than 255 characters?

推荐答案

一般来说,一个VARCHAR字段中,存储在每个字段中的数据量决定了其在磁盘上的占用空间,而不是最大大小(与总是具有相同占用空间的CHAR字段不同)。

In general, for a VARCHAR field, the amount of data stored in each field determines its footprint on the disk rather than the maximum size (unlike a CHAR field which always has the same footprint).

存储在900字节索引的所有字段内的总数据有一个上限(字符长度的900字节索引大小限制)。

There is an upper limit on the total data stored within all fields of an index of 900 bytes (900 byte index size limit in character length).

你做这个领域,人们越有可能尝试用于除了你想要的目的之外 - 屏幕不动产需要显示价值的越大 - 所以尝试选择正确的强>大小,而不是假设如果你尽可能的大,它会节省你不得不重新设计。

The larger you make the field, the more likely people will try to use for purposes other than what you intended - and the greater the screen real-estate required to show the value - so its good practice to try to pick the right size, rather than assuming that if you make it as large as possible it will save you having to revisit the design.

这篇关于VARCHAR大小限制了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆