Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the limit of the field type BIGINT in SQL?

Tags:

sql

bigint

What is the limit of the field type BIGINT in SQL?

is 100000235882380 or 100000466411115 acceptable? (That is ID from facebook)

like image 363
ozsenegal Avatar asked Dec 10 '10 12:12

ozsenegal


People also ask

What is the limit of BIGINT?

A big integer is a binary integer with a precision of 63 bits. The range of big integers is -9223372036854775808 to +9223372036854775807.

What does BIGINT 20 mean?

The 20 in INT(20) and BIGINT(20) means almost nothing. It's a hint for display width. It has nothing to do with storage, nor the range of values that column will accept.

How many numbers can BIGINT hold?

A BIGINT is always 8 bytes and can store -9223372036854775808 to 9223372036854775807 (signed) or 0 to 18446744073709551615 (unsigned).


2 Answers

Check the manual of the RDBMS you're using. It may not be the same in all systems.

MySQL:
https://dev.mysql.com/doc/refman/5.7/en/integer-types.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

DB2:
http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.sqlref/db2z_biginteger.htm

like image 153
Dan Grossman Avatar answered Oct 03 '22 14:10

Dan Grossman


Yes, according to int, bigint, smallint, and tinyint (Transact-SQL):

bigint -2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807)

like image 36
Andrew Hare Avatar answered Oct 03 '22 15:10

Andrew Hare