Engine by engine
BIGINT is 8 bytes in SQL Server, PostgreSQL and MySQL; SQLite folds it into INTEGER and Oracle needs NUMBER(19) to match it.
| Motor | Tipo | Armazenamento | Notas |
|---|---|---|---|
| SQL Server |
BIGINT
|
8 bytes | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. |
| PostgreSQL |
BIGINT (INT8)
|
8 bytes | Same range; the type behind BIGSERIAL. |
| MySQL |
BIGINT
|
8 bytes | BIGINT UNSIGNED reaches 18,446,744,073,709,551,615. |
| SQLite |
INTEGER
|
up to 8 bytes | Already 64-bit signed at the top of its variable-width range; INTEGER PRIMARY KEY is the rowid. |
| Oracle |
NUMBER(19)
|
1-12 bytes | No native BIGINT; NUMBER(19) covers signed 64-bit (and a little more), NUMBER(20) covers the unsigned range. |
Gotchas
Where the engines disagree. These tend to surface as bugs during a migration or a port.
- JavaScript and JSON lose precision above 2^53: round-tripping a BIGINT ID through JSON.parse corrupts it, so serialize 64-bit integers as strings.
- MySQL's BIGINT UNSIGNED exceeds every other engine's signed 64-bit: values above 9.2e18 fail to import unchanged.
- Oracle's NUMBER(19) is decimal, not two's-complement binary: arithmetic stays exact to 38 digits instead of overflowing at 2^63, and the limit only shows up as ORA-01438 when a result is stored back into the column.
Common questions
BIGINT or INT for primary keys?
BIGINT by default. The INT-to-BIGINT migration on a hot table is painful, and 2.1 billion IDs arrive sooner than planned on event tables.
Why is my BIGINT wrong in JavaScript?
JSON numbers are IEEE doubles, exact only to 2^53. Send 64-bit integers as strings and parse them with BigInt where needed.
Related on SQLly
// map types before you move data
Map a type to the other four engines
The free type converter maps a type from one engine to its closest equivalent in the others and says where storage, precision or behaviour differ. The desktop app does the same mapping while you edit.