SQL Int(N) 的大小是多少?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4151259/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Whats the size of an SQL Int(N)?
提问by Michael
Simple question. I have tried searching on Google and after about 6 searches, I figured it would be faster here.
简单的问题。我试过在谷歌上搜索,经过大约 6 次搜索,我认为这里会更快。
How big is an int in SQL?
SQL 中的 int 有多大?
-- table creation statement.
intcolumn INT(N) NOT NULL,
-- more table creation statement.
How big is that INT(N)
element? What's its range? Is it 2^N or is it N Bytes long? (2 ^ 8N)? Or even something else I have no idea about?
这个INT(N)
元素有多大?它的范围是多少?它是 2^N 还是 N 字节长?(2^8N)?或者甚至是我不知道的其他事情?
采纳答案by Matthew Flaschen
It depends on the database. MySQL has an extensionwhere INT(N) means an INT with a display widthof 4 decimal digits. This information is maintained in the metadata.
这取决于数据库。MySQL 有一个扩展,其中 INT(N) 表示显示宽度为 4 位十进制数字的 INT 。该信息保存在元数据中。
The INT itself is still 4 bytes, and values 10000 and greater can be stored (and probably displayed, but this depends how the application uses the result set).
INT 本身仍然是 4 个字节,并且可以存储 10000 和更大的值(并且可能会显示,但这取决于应用程序如何使用结果集)。