BIGINT
BIGINT is a 64-bit signed integer data type that occupies 8 bytes of storage and is used to store large integers beyond the INT range.
Syntax
Value Range
| Bound | Value |
|---|---|
| Minimum | -9,223,372,036,854,775,808 |
| Maximum | 9,223,372,036,854,775,807 |
Literal suffix: L (e.g., 123456789L). If a numeric value exceeds the INT range, it is automatically recognized as BIGINT even without the L suffix.
Examples
-
Use the BIGINT literal suffix:
Returns:
123456789 -
Convert integers to BIGINT (boundary values):
Returns:
9223372036854775807,-9223372036854775808 -
Convert a floating-point number to BIGINT (decimal part truncated):
Returns:
123 -
Overflow behavior (out-of-range returns NULL):
Returns:
NULL -
NULL value handling:
Returns:
NULL
Notes
- The value range is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. CAST conversions that exceed the range return NULL without raising an error.
- The literal suffix is
L(case-insensitive), e.g.,1L,-1L. Integer literals exceeding the INT range are automatically treated as BIGINT. - When casting a floating-point number to BIGINT, the decimal part is simply truncated (no rounding).
- CAST of an invalid string (e.g.,
'abc') returns NULL. - BIGINT is the preferred type for scenarios requiring storage of large integers such as IDs and millisecond timestamps.
