BIGINT is a fixed-precision integer data type that occupies 8 bytes (64 bits) of storage and represents whole numbers without a fractional component. In Standard SQL the type is signed, giving a range of -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Many dialects such as MySQL and MariaDB also offer an UNSIGNED modifier that shifts the range to 0 through 18,446,744,073,709,551,615.Because BIGINT can safely represent any 32-bit and 53-bit (JavaScript) integer, it is frequently chosen for high-volume primary keys, surrogate keys, epoch timestamps in milliseconds, monetary amounts in smallest currency units, and any counter expected to exceed the 32-bit INT range. Compared with DECIMAL or NUMERIC, BIGINT requires less storage and performs arithmetic faster because it has no scale metadata.Dialect differences exist:- PostgreSQL: BIGINT is an alias for INT8. BIGSERIAL creates an auto-incrementing BIGINT column plus sequence.- MySQL/MariaDB: Optional display width (deprecated) and optional UNSIGNED.- SQL Server: BIGINT is always signed; identity columns can auto-increment.- Oracle: Use NUMBER(19) for equivalent precision because Oracle lacks a dedicated BIGINT keyword.- SQLite: Uses dynamic typing; any integer up to 8 bytes is stored as INTEGER, so BIGINT aliases to INTEGER affinity.Caveats:- Choosing BIGINT when INT would suffice increases disk and index size.- Overflow results in errors or wraparound depending on dialect.- Client libraries in weakly typed languages (JavaScript, JSON) may lose precision for values larger than 9,007,199,254,740,991 (2^53-1).
INT, INTEGER, SMALLINT, TINYINT, BIGSERIAL, IDENTITY, NUMERIC, DECIMAL, AUTO_INCREMENT, SEQUENCE
SQL:1999
BIGINT is chosen for columns that need to store integers larger than the 32-bit INT range, such as high-volume primary keys, epoch timestamps, and monetary amounts in cents.
BIGINT always uses 8 bytes of disk and memory regardless of the actual value stored.
- PostgreSQL: use BIGSERIAL or create a BIGINT column with DEFAULT nextval('seq').- MySQL: add AUTO_INCREMENT to a BIGINT UNSIGNED column.- SQL Server: declare BIGINT IDENTITY(1,1).
Sequential scans are slightly slower and indexes are larger compared with INT because of the extra 4 bytes, but for most workloads the difference is negligible relative to the safety of avoiding overflow.