BIGINT

BIGINT is a data type used to represent 8-byte signed integers. Its value range is from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. This type is typically used to store very large integer values.

Syntax

BIGINT [ + | - ] digit [ ... ] [L]
  • digit: Represents any digit from 0 to 9.
  • L: Represents a literal suffix used to indicate that this is a BIGINT type value. If the value is outside the INT range, it will automatically be converted to BIGINT type even without the L suffix.

Example

  1. Insert a positive BIGINT value:
INSERT INTO my_table (my_column) VALUES (+1L);
  1. Insert a negative BIGINT value:
INSERT INTO my_table (my_column) VALUES (-1L);
  1. Insert a BIGINT value without the L suffix (if the value is within the INT range, it will be implicitly converted to INT):
INSERT INTO my_table (my_column) VALUES (123456789);
  1. Use BIGINT type values for comparison in queries:
SELECT * FROM my_table WHERE my_column = 9223372036854775807;
5. Use the `CAST` function to convert other types of values to `BIGINT`:
SELECT CAST(123.456 AS BIGINT);

Notes

  • When using the BIGINT type to store values, please ensure the values are within the allowed range, otherwise it may cause overflow errors.
  • When performing numerical comparisons or calculations, be aware of implicit conversions between data types to avoid unexpected results.