// data type reference

BOOLEAN

Of the five engines, only PostgreSQL has a native SQL BOOLEAN in every version. SQL Server uses BIT, MySQL aliases BOOLEAN to TINYINT(1), SQLite stores integers, and Oracle added BOOLEAN to SQL only in 23ai.

Missing in
None of the five
Gotchas
5 listed

Engine by engine

One engine, PostgreSQL, has a true 1-byte BOOLEAN. SQL Server's BIT stores 0/1/NULL in one shared byte, MySQL's BOOLEAN is TINYINT(1), SQLite uses INTEGER, and Oracle got SQL BOOLEAN in 23ai.

BOOLEAN in SQL Server, PostgreSQL, MySQL, SQLite and Oracle: type name, storage and notes
Engine Typ Speicher Notizen
SQL Server BIT 1 byte per column Stores 0, 1 or NULL only; up to 8 BIT columns in a table share one byte. There are no TRUE or FALSE keywords.
PostgreSQL BOOLEAN 1 byte TRUE, FALSE and NULL literals; displays as t and f in text output.
MySQL TINYINT(1) 1 byte BOOLEAN is an alias for TINYINT(1); TRUE and FALSE literals map to 1 and 0.
SQLite INTEGER 1 to 8 bytes No boolean type: 0 and 1 by convention, with TRUE and FALSE keywords supported since 3.23.0 (2018).
Oracle BOOLEAN 1 byte Added to SQL in Oracle 23ai; before that, BOOLEAN existed only in PL/SQL and columns used NUMBER(1) or CHAR(1).

Gotchas

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

  1. SQL Server has no TRUE or FALSE literals and no boolean value type: WHERE is_active alone is a syntax error (write is_active = 1), and SELECT a > b fails; wrap it in CASE or IIF.
  2. PostgreSQL's BOOLEAN prints as t and f in psql and text-mode results, but casts to text as 'true' and 'false'. Code that parses raw output has to handle both.
  3. MySQL's BOOLEAN is TINYINT(1) with no constraint: the column happily stores 2 or 42, and clients report it as a number, so 'is a boolean' is a convention, not a guarantee.
  4. SQLite stores whatever integer you insert; TRUE and FALSE keywords resolve to 1 and 0, but nothing stops -1 or 7 from entering the column without a CHECK.
  5. Before 23ai, Oracle's BOOLEAN existed only in PL/SQL: it could not be a column type, and a function returning BOOLEAN could not be called from a SELECT, hence the NUMBER(1)/CHAR(1) emulation everywhere.

Common questions

Does SQL Server have a BOOLEAN type?

No. SQL Server has BIT, which stores 0, 1 and NULL in one byte (up to 8 BIT columns share a byte), but there is no TRUE/FALSE literal and no boolean expression type.

Is MySQL's BOOLEAN a real boolean?

No. BOOLEAN is an alias for TINYINT(1) and TRUE/FALSE are aliases for 1/0. The column accepts any tinyint value unless you add a CHECK constraint.

When did Oracle support BOOLEAN in SQL?

Oracle Database 23ai (first released as 23c Free in 2023). Before that, BOOLEAN worked only in PL/SQL, and SQL columns emulated it with NUMBER(1) or CHAR(1).

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