MySQL VARCHAR 大小?
如果我有一个 200 个字符的 VARCHAR 并且输入了一个 100 个字符的字符串,那么它会使用 200 个字节还是仅使用字符串的实际大小?
If I have a VARCHAR of 200 characters and that I put a string of 100 characters, will it use 200 bytes or it will just use the actual size of the string?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
100 个字符。
这是
varchar
中的 var(变量):您只存储您输入的内容(以及额外的 2 个字节来存储最大长度 65535)如果它是
char( 200)
那么你总是存储 200 个字符,并用 100 个空格填充请参阅文档:"CHAR 和 VARCHAR 类型"
100 characters.
This is the var (variable) in
varchar
: you only store what you enter (and an extra 2 bytes to store length upto 65535)If it was
char(200)
then you'd always store 200 characters, padded with 100 spacesSee the docs: "The CHAR and VARCHAR Types"
http://dev.mysql.com/doc/refman/5.0/en/char.html< /a>
http://dev.mysql.com/doc/refman/5.0/en/char.html
实际上,它需要 101 个字节。
MySQL 参考
Actually, it will takes 101 bytes.
MySQL Reference