Engine by engine
1 byte, 0-255 in SQL Server; signed -128 to 127 by default in MySQL; nowhere else has it, so SMALLINT or NUMBER(3) stands in.
| Moteur | Type | Stockage | Notes |
|---|---|---|---|
| SQL Server |
TINYINT
|
1 byte | Unsigned only: 0 to 255. There is no signed tinyint here. |
| PostgreSQL |
no TINYINT - use SMALLINT
Workaround
|
2 bytes (SMALLINT) | PostgreSQL's smallest integer is SMALLINT; a domain with CHECK can narrow it. |
| MySQL |
TINYINT
|
1 byte | Signed -128 to 127 by default; TINYINT UNSIGNED reaches 0 to 255. |
| SQLite |
TINYINT (INTEGER affinity)
|
variable, 1-8 bytes | Any type name containing INT gets INTEGER affinity, so TINYINT stores full 64-bit integers. |
| Oracle |
NUMBER(3)
|
1-4 bytes | No tinyint; NUMBER(3) allows -999 to 999 in variable-length decimal storage, so add a CHECK for 0-255. |
Gotchas
Where the engines disagree. These tend to surface as bugs during a migration or a port.
- SQL Server's TINYINT is unsigned (0-255) while MySQL's default is signed (-128 to 127): the same column name holds different ranges.
- MySQL's TINYINT(1) is treated as a boolean by many clients, but the (1) is display width only - the column still stores the full tinyint range.
- PostgreSQL and Oracle have no 1-byte integer: SMALLINT costs 2 bytes and NUMBER(3) up to 4, and neither stops a 300 from going in without a CHECK constraint.
- SQLite accepts the type name but gives it INTEGER affinity, so a TINYINT column happily stores 9,223,372,036,854,775,807.
Common questions
How do I get a 1-byte integer in PostgreSQL?
You cannot. The smallest is SMALLINT at 2 bytes. Add a CHECK constraint or a domain to enforce a smaller range.
What is TINYINT(1) in MySQL?
A TINYINT declared with display width 1. Clients often map it to boolean, but it stores the full signed (or unsigned) tinyint range.
Is SQL Server's TINYINT signed?
No. It only stores 0 to 255. For -128 to 127 you need SMALLINT, which is 2 bytes.
Related on SQLly
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.