Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

max value represented by bigint

Tags:

sql

tsql

Is there a way to get the max value that can be stored in a bigint, without hardcoding it?

Is there a function or a constant that returns/contains this value?

like image 567
Corovei Andrei Avatar asked Aug 17 '11 12:08

Corovei Andrei


People also ask

What is the max length of BIGINT in SQL Server?

The BigInt data type in SQL Server is the 64-bit representation of an integer. It takes up 8 bytes of storage. It can range from -2^63 (-9,223,372,036,854,775,808) to 2^63 (9,223,372,036,854,775,807).

How many numbers can BIGINT hold?

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

What is BIGINT format?

Description: BIGINT is the SQL99-compliant 64-bit signed integer type. It is available in Dialect 3 only. BIGINT numbers range from -263 .. 263-1, or -9,223,372,036,854,775,808 ..

What is the max value of INT in SQL Server?

Maximum value is 2147483647.

Is Long bigger than BIGINT?

BigInteger Larger Than Long. The signed long has a minimum value of -263 (1000 0000 … 0000) and a maximum value of 263-1 (0111 1111 … 1111). To create a number over those limits, we need to use the BigInteger class.


1 Answers

A bigint is always going to support

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

SQL Server TSQL does not define this as a constant, but it is always going to be -2^63 to 2^63 - 1

Ref.: int, bigint, smallint, and tinyint (Transact-SQL)

like image 195
Mitch Wheat Avatar answered Nov 11 '22 13:11

Mitch Wheat