SQL 中字段类型 BIGINT 的限制是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4408808/
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
What is the limit of the field type BIGINT in SQL?
提问by ozsenegal
What is the limit of the field type BIGINT in SQL?
SQL 中字段类型 BIGINT 的限制是什么?
is 100000235882380 or 100000466411115 acceptable? (That is ID from facebook)
100000235882380 或 100000466411115 是否可以接受?(那是facebook的ID)
回答by Dan Grossman
Check the manual of the RDBMS you're using. It may not be the same in all systems.
检查您正在使用的 RDBMS 的手册。它可能在所有系统中都不相同。
MySQL:
https://dev.mysql.com/doc/refman/5.7/en/integer-types.html
MySQL:https:
//dev.mysql.com/doc/refman/5.7/en/integer-types.html
PostgreSQL:
https://www.postgresql.org/docs/10/static/datatype-numeric.html
PostgreSQL:https:
//www.postgresql.org/docs/10/static/datatype-numeric.html
SQL Server (Transact-SQL):
https://docs.microsoft.com/en-us/sql/t-sql/data-types/int-bigint-smallint-and-tinyint-transact-sql
SQL Server (Transact-SQL):https:
//docs.microsoft.com/en-us/sql/t-sql/data-types/int-bigint-smallint-and-tinyint-transact-sql
DB2:http:
//publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.sqlref/db2z_biginteger.htm
回答by Andrew Hare
Yes, according to int, bigint, smallint, and tinyint (Transact-SQL):
是的,根据int、bigint、smallint 和 tinyint (Transact-SQL):
bigint
-2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807)
大整数
-2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807)
回答by John Parker
It depends on the RDBMS. For example, the maxiumum values of a BIGINT are 9223372036854775807
(for signed) or 18446744073709551615
(for un-signed) on MySQL.
这取决于 RDBMS。例如,BIGINT 的最大值在 MySQL 上是9223372036854775807
(对于有符号的)或18446744073709551615
(对于无符号的)。
See the Numeric Typessection of the docs for the full details.
有关完整详细信息,请参阅文档的数字类型部分。
回答by rustyx
Nothing to worry about. BIGINT can store much larger values than the ones you have.
没什么可担心的。BIGINT 可以存储比您拥有的值大得多的值。
At a minimum up to 9,223,372,036,854,775,807.
最低可达 9,223,372,036,854,775,807。