SQL Data Types Reference

Updated · 2 min read

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 valuePostgreSQLMySQLSQL ServerMS Access (legacy)
Whole numberINTEGER, BIGINT, SMALLINTINT, BIGINT, SMALLINT, TINYINTINT, BIGINT, SMALLINT, TINYINTNumber (Long Integer), Integer, Byte
Exact decimal (money)NUMERIC(p,s)DECIMAL(p,s)DECIMAL(p,s), MONEYCurrency, Decimal
Approximate numberREAL, DOUBLE PRECISIONFLOAT, DOUBLEREAL, FLOATSingle, Double
Fixed-length textCHAR(n)CHAR(n)CHAR(n), NCHAR(n)Short Text
Variable-length textVARCHAR(n), TEXTVARCHAR(n), TEXTVARCHAR(n), NVARCHAR(n), NVARCHAR(MAX)Short Text (255), Long Text
True or falseBOOLEANBOOLEAN (TINYINT(1))BITYes/No
DateDATEDATEDATEDate/Time
Time of dayTIMETIMETIMEDate/Time
Date and timeTIMESTAMPDATETIMEDATETIME2Date/Time
Date and time with time zoneTIMESTAMPTZTIMESTAMP (stored in UTC)DATETIMEOFFSETNot available
Length of timeINTERVALNot available (use numbers)Not available (use numbers)Not available
Auto-numbered idGENERATED AS IDENTITY, SERIALAUTO_INCREMENTIDENTITY(1,1)AutoNumber
Universally unique idUUIDCHAR(36) or BINARY(16)UNIQUEIDENTIFIERReplication ID
JSONJSONB, JSONJSONJSON (2025), NVARCHAR(MAX) beforeNot available
Binary dataBYTEABLOB, VARBINARY(n)VARBINARY(n), VARBINARY(MAX)OLE Object, Attachment
ArrayINTEGER[], TEXT[]Not available (use JSON)Not availableNot 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?