MySQL int 定义解释
多年来,当我为 MySQL 表创建 bigint(12) 类型的新列时,我一直假设该字段仅限于最多 12 位的整数。然而,我最近注意到,可以在 bigint(12) 定义的列中写入和选择最多 16 位数字的值,而不会出现任何警告或问题。
有人可以帮助我理解为什么会出现这种情况以及该列定义的实际含义吗?提前致谢!
For years I have been under the assumption when I create a new column of type bigint(12) for a MySQL table that the field is limited to integers with up to 12 digits. However, I recently noticed that values up to 16 digits are able to be written into and selected out of a bigint(12) defined column without any warnings or issues.
Can someone please help me understand why this is the case and what that column definition actually means? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
bigint(12) 根本没有被截断。 12 用于显示目的。
查看数字类型
bigint(12) is not truncated at all. The 12 is used for display purposes.
Have a look at Numeric Types
阅读 MySql 文档中的
数字类型属性
部分 INT(4)指定显示宽度为四位的INTread
Numeric Type Attributes
section from MySql documentation INT(4) specifies an INT with a display width of four digits