// data type reference

SMALLINT

SMALLINT halves INT's storage for columns with a known small range.

Family
Integers
Missing in
None of the five
Gotchas
3 listed

Engine by engine

2 bytes and -32,768 to 32,767 in three engines; MySQL adds an UNSIGNED variant; Oracle and SQLite fold it into their general numeric types.

SMALLINT in SQL Server, PostgreSQL, MySQL, SQLite and Oracle: type name, storage and notes
Engine Type Storage Notes
SQL Server SMALLINT 2 bytes Signed -32,768 to 32,767. There is no unsigned variant.
PostgreSQL SMALLINT (INT2) 2 bytes Same range; INT2 is the internal spelling.
MySQL SMALLINT 2 bytes Signed by default; SMALLINT UNSIGNED reaches 65,535.
SQLite SMALLINT (INTEGER affinity) variable, 1-8 bytes Accepted as a type name but behaves exactly like INTEGER.
Oracle NUMBER(5) 1-5 bytes Oracle accepts SMALLINT but maps it to NUMBER(38); NUMBER(5) allows -99,999 to 99,999, wider than a real SMALLINT.

Gotchas

Where the engines disagree. These tend to surface as bugs during a migration or a port.

  1. MySQL's SMALLINT UNSIGNED (0-65,535) has no counterpart in SQL Server or PostgreSQL: porting it needs a CHECK constraint on the signed type.
  2. SQLite ignores the size hint entirely: SMALLINT maps to INTEGER affinity and still stores up to 8-byte values.
  3. Oracle's SMALLINT keyword is just NUMBER(38). NUMBER(5) is the usual stand-in, but it allows up to 99,999 and rounds fractional input (2.5 becomes 3) instead of rejecting it.

Common questions

When should I use SMALLINT instead of INT?

When the range provably stays small and the table is large: 2 bytes instead of 4 per row and per index entry. Alignment padding often eats the saving in PostgreSQL, so choose it for the range, not the bytes.

Does SQLite store SMALLINT in 2 bytes?

Not by declaration. SQLite uses INTEGER affinity and picks 1-8 bytes per value from its magnitude, so small values are compact anyway.

// 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.