SQL Data Types Reference
Each database names its types a little differently. This table lines up the common ones, so you can translate a table definition from one database to another. For what each type stores and how to choose, see SQL Data Types.
| Kind of value | PostgreSQL | MySQL | SQL Server | MS Access (legacy) |
|---|---|---|---|---|
| Whole number | INTEGER, BIGINT, SMALLINT | INT, BIGINT, SMALLINT, TINYINT | INT, BIGINT, SMALLINT, TINYINT | Number (Long Integer), Integer, Byte |
| Exact decimal (money) | NUMERIC(p,s) | DECIMAL(p,s) | DECIMAL(p,s), MONEY | Currency, Decimal |
| Approximate number | REAL, DOUBLE PRECISION | FLOAT, DOUBLE | REAL, FLOAT | Single, Double |
| Fixed-length text | CHAR(n) | CHAR(n) | CHAR(n), NCHAR(n) | Short Text |
| Variable-length text | VARCHAR(n), TEXT | VARCHAR(n), TEXT | VARCHAR(n), NVARCHAR(n), NVARCHAR(MAX) | Short Text (255), Long Text |
| True or false | BOOLEAN | BOOLEAN (TINYINT(1)) | BIT | Yes/No |
| Date | DATE | DATE | DATE | Date/Time |
| Time of day | TIME | TIME | TIME | Date/Time |
| Date and time | TIMESTAMP | DATETIME | DATETIME2 | Date/Time |
| Date and time with time zone | TIMESTAMPTZ | TIMESTAMP (stored in UTC) | DATETIMEOFFSET | Not available |
| Length of time | INTERVAL | Not available (use numbers) | Not available (use numbers) | Not available |
| Auto-numbered id | GENERATED AS IDENTITY, SERIAL | AUTO_INCREMENT | IDENTITY(1,1) | AutoNumber |
| Universally unique id | UUID | CHAR(36) or BINARY(16) | UNIQUEIDENTIFIER | Replication ID |
| JSON | JSONB, JSON | JSON | JSON (2025), NVARCHAR(MAX) before | Not available |
| Binary data | BYTEA | BLOB, VARBINARY(n) | VARBINARY(n), VARBINARY(MAX) | OLE Object, Attachment |
| Array | INTEGER[], TEXT[] | Not available (use JSON) | Not available | Not available |
Check a Value's Type in PostgreSQL
SQL▶ Try it
SELECT pg_typeof(fee_usd) AS fee_type,
pg_typeof(title) AS title_type,
pg_typeof(joined_on) AS date_type,
pg_typeof(0.1 + 0.2) AS literal_type,
0.1::double precision + 0.2::double precision AS float_sum,
0.1 + 0.2 AS numeric_sum
FROM courses, students
WHERE course_id = 1 AND student_id = 101;Output
fee_type | title_type | date_type | literal_type | float_sum | numeric_sum
----------+-------------------+-----------+--------------+---------------------+-------------
numeric | character varying | date | numeric | 0.30000000000000004 | 0.3
(1 row)0.1 + 0.2 written as literals is numeric and exactly 0.3. As double precision, the same sum is 0.30000000000000004, because binary floating point can't store 0.1 or 0.2 exactly. Oracle uses NUMBER, VARCHAR2 and DATE (which includes a time); SQLite stores values by type affinity, see Dialect Differences Cheat Sheet.
Was this tutorial helpful?