Skip to content

PostgreSQL data type reference

PostgreSQL to MySQL, SQL Server, Oracle and Db2: data type mapping

Every PostgreSQL column type we map, what it becomes in each target database, and what PostgreSQL has that the others do not.

Updated · from our Database Migration Platform’s type rules

Where these mappings come from

The defaults our platform proposes

Each target type below is the default our Database Migration Platform proposes for a PostgreSQL column, and every project can override any of them. The notes are what we check when planning a migration: where a value can round, lose information or behave differently on the new engine. “Same type” means the type name is kept; check binary lengths and time precision on the target.

PostgreSQL to each target: testing status
PostgreSQL → PostgreSQLAutomated end-to-end test
PostgreSQL → MySQLSupported, not yet tested
PostgreSQL → SQL ServerSupported, not yet tested
PostgreSQL → OracleSupported, not yet tested
PostgreSQL → Db2Supported, not yet tested

Numbers and booleans

  • smallint, smallserial

    PostgreSQL
    Same type
    MySQL
    SMALLINT
    SQL Server
    SMALLINT
    Oracle
    NUMBER(5)
    Db2
    SMALLINT

    A serial column’s sequence does not move with the type; recreate it as the target’s identity.

  • integer, serial

    PostgreSQL
    Same type
    MySQL
    INT
    SQL Server
    INT
    Oracle
    NUMBER(10)
    Db2
    INTEGER

    As above for serial.

  • bigint, bigserial

    PostgreSQL
    Same type
    MySQL
    BIGINT
    SQL Server
    BIGINT
    Oracle
    NUMBER(19)
    Db2
    BIGINT

    As above for bigserial.

  • numeric(p,s)

    PostgreSQL
    Same type
    MySQL
    DECIMAL(p, s)
    SQL Server
    DECIMAL(p, s)
    Oracle
    NUMBER(p, s)
    Db2
    DECIMAL(p, s)

    Precision and scale are kept.

  • numeric, money

    PostgreSQL
    Same type
    MySQL
    DECIMAL
    SQL Server
    DECIMAL
    Oracle
    NUMBER
    Db2
    DECIMAL

    Unbounded numeric has no fixed scale. A DECIMAL without precision has a small default elsewhere (MySQL 10,0; SQL Server 18,0; Db2 5,0), so set an explicit precision for those targets or values round.

  • real

    PostgreSQL
    Same type
    MySQL
    FLOAT
    SQL Server
    REAL
    Oracle
    BINARY_FLOAT
    Db2
    REAL

    4-byte floating point.

  • double precision

    PostgreSQL
    Same type
    MySQL
    DOUBLE
    SQL Server
    FLOAT
    Oracle
    BINARY_DOUBLE
    Db2
    DOUBLE

    8-byte floating point.

  • boolean

    PostgreSQL
    Same type
    MySQL
    TINYINT(1)
    SQL Server
    BIT
    Oracle
    NUMBER(1)
    Db2
    SMALLINT

    A true boolean only on PostgreSQL; BIT (0 or 1) on SQL Server and 0 or 1 elsewhere. Oracle 23ai has BOOLEAN, but the default is NUMBER(1).

Text and JSON

  • char(n)

    PostgreSQL
    Same type
    MySQL
    CHAR(n)
    SQL Server
    NCHAR(n)
    Oracle
    CHAR(n)
    Db2
    CHAR(n)

    Padded with spaces.

  • varchar(n)

    PostgreSQL
    Same type
    MySQL
    VARCHAR(n)
    SQL Server
    NVARCHAR(n)
    Oracle
    VARCHAR2(n)
    Db2
    VARCHAR(n)

    Counts characters. Oracle and Db2 count bytes by default, so multi-byte text can overflow the same n there.

  • text

    PostgreSQL
    Same type
    MySQL
    LONGTEXT
    SQL Server
    NVARCHAR(MAX)
    Oracle
    CLOB
    Db2
    CLOB

    Lands as the target’s large-text type (CLOB on Oracle and Db2), which cannot be a key or a plain index there. Override key columns to a VARCHAR with a length.

  • json, jsonb, hstore

    PostgreSQL
    Same type
    MySQL
    JSON
    SQL Server
    NVARCHAR(MAX)
    Oracle
    CLOB
    Db2
    CLOB

    Native JSON on MySQL; text (NVARCHAR(MAX) or CLOB) on SQL Server, Oracle and Db2. GIN indexes on jsonb have no direct equivalent. hstore’s text form ("a"=>"b") is not JSON: convert it with hstore_to_json before a MySQL JSON column will take it.

  • xml

    PostgreSQL
    Same type
    MySQL
    LONGTEXT
    SQL Server
    NVARCHAR(MAX)
    Oracle
    CLOB
    Db2
    CLOB

    Lands as text.

  • inet, cidr, macaddr, bit, varbit, interval, tsvector, citext

    PostgreSQL
    Same type
    MySQL
    VARCHAR(n) or TEXT
    SQL Server
    NVARCHAR(n) or NVARCHAR(MAX)
    Oracle
    VARCHAR2(n) or CLOB
    Db2
    VARCHAR(n) or CLOB

    Land as their text form (with a length where the driver reports one, otherwise as unbounded text), so the operators that went with them (network containment, interval arithmetic, full-text search, case-insensitive compare) need rebuilding.

Dates, binary and identifiers

  • date

    PostgreSQL
    Same type
    MySQL
    DATE
    SQL Server
    DATE
    Oracle
    DATE
    Db2
    DATE

    Oracle DATE also carries a time of day (set to midnight).

  • time, timetz

    PostgreSQL
    Same type
    MySQL
    TIME
    SQL Server
    TIME
    Oracle
    TIMESTAMP
    Db2
    TIME

    The zone of timetz is dropped. Oracle has no time-only type, so it becomes a TIMESTAMP.

  • timestamp

    PostgreSQL
    Same type
    MySQL
    DATETIME(6)
    SQL Server
    DATETIME2
    Oracle
    TIMESTAMP
    Db2
    TIMESTAMP

    Microsecond precision fits every target.

  • timestamptz

    PostgreSQL
    Same type
    MySQL
    DATETIME(6)
    SQL Server
    DATETIMEOFFSET
    Oracle
    TIMESTAMP WITH TIME ZONE
    Db2
    TIMESTAMP

    Keeps the instant on SQL Server and Oracle; MySQL and Db2 have no zone, so values land as plain timestamps. Load them in UTC.

  • bytea

    PostgreSQL
    Same type
    MySQL
    LONGBLOB
    SQL Server
    VARBINARY(MAX)
    Oracle
    BLOB
    Db2
    BLOB

    Lands as the target’s large binary type.

  • uuid

    PostgreSQL
    Same type
    MySQL
    CHAR(36)
    SQL Server
    UNIQUEIDENTIFIER
    Oracle
    VARCHAR2(36)
    Db2
    VARCHAR(36)

    Native on SQL Server; text (36 characters) on MySQL, Oracle and Db2. Compare case-insensitively.

  • geometry, geography (PostGIS)

    PostgreSQL
    Same type
    MySQL
    LONGBLOB
    SQL Server
    VARBINARY(MAX)
    Oracle
    BLOB
    Db2
    BLOB

    Lands as binary, so spatial queries do not carry over.

  • arrays, ranges, composite, enum and domain types

    PostgreSQL
    Same type
    MySQL
    TEXT
    SQL Server
    NVARCHAR(MAX)
    Oracle
    CLOB
    Db2
    CLOB

    Not in the default rules, so these land as text and are flagged for review. A domain reports its own name, so even a domain over integer lands as text.

Planning a PostgreSQL migration? We can map your schema and run the move with change data capture.

Database migration services

Beyond types

What a type table does not show

The schema can convert cleanly and the application still break. These are the usual reasons with PostgreSQL.

01

PostgreSQL to PostgreSQL

Between PostgreSQL databases, for example an upgrade or a move to a managed service, types keep their names, and char/varchar lengths and numeric precision and scale carry over. Check bit(n) and time and timestamp precision on the target.

02

Types other engines lack

Arrays, ranges, composite types, network types and full-text search columns have no equivalent elsewhere. They land as text so nothing is lost, and the logic that used them is rebuilt on the target.

03

Unbounded numeric

PostgreSQL allows NUMERIC with no precision. MySQL, SQL Server and Db2 need a precision and scale, so set them explicitly where the source column has none.

Notes per target

Landing in each database

Into MySQL

  • Create the database with utf8mb4. The older utf8 (utf8mb3) cannot store emoji and some other characters.
  • All columns except TEXT and BLOB share a 65,535-byte row limit, and utf8mb4 counts up to 4 bytes a character. CHAR(n) allows at most 255.
  • Text with no declared length lands as TEXT, which holds 64 KB: override to MEDIUMTEXT or LONGTEXT for larger values. TEXT and BLOB columns need a prefix length to be indexed.
  • TIME has no fractional seconds unless declared TIME(6), so fractions are lost. DATETIME(6) holds microseconds but no time zone.
  • A boolean arrives as TINYINT(1): 0 or 1, though the column also accepts other small integers.

Into SQL Server

  • Text lands as NVARCHAR/NCHAR, so Unicode is safe. NVARCHAR(n) allows n up to 4,000: longer declared lengths need NVARCHAR(MAX), which cannot be an index key.
  • Most SQL Server databases compare case-insensitively, unlike PostgreSQL, Oracle and Db2.
  • Identity columns are not re-seeded automatically: run DBCC CHECKIDENT after the load.
  • DATETIME2 keeps up to 100 ns. DATETIMEOFFSET keeps an offset, but values from a UTC source (such as PostgreSQL timestamptz) arrive as +00:00.
  • JSON lands as NVARCHAR(MAX). SQL Server 2025 has a native json type if you want one.
  • There is no boolean type: BIT holds 0, 1 or NULL.

Into Oracle

  • Oracle treats an empty string as NULL. Values that were '' in the source become NULL, and NOT NULL text columns can reject them.
  • Integers land as NUMBER(5), NUMBER(10) and NUMBER(19); booleans as NUMBER(1) (Oracle 23ai has BOOLEAN, but it is not the default); UUIDs as VARCHAR2(36) text.
  • Identity columns are not re-seeded automatically: use ALTER TABLE … MODIFY … START WITH LIMIT VALUE after the load.
  • VARCHAR2 holds 4,000 bytes unless MAX_STRING_SIZE is EXTENDED (32,767); a longer declared length needs a CLOB override. Text with no length lands as CLOB, which cannot be compared with = or used in a plain index.
  • TIME values land as TIMESTAMP, with a date part added.

Into Db2

  • Booleans land as SMALLINT (0 or 1) and UUIDs as VARCHAR(36) text.
  • Timestamps land as plain TIMESTAMP, which keeps 6 fractional digits and no time zone: values with a zone are stored without it, so convert them to UTC first. TIME has no fractional seconds.
  • Identity columns are not re-seeded automatically: use ALTER TABLE … ALTER COLUMN … RESTART WITH after the load.
  • A VARCHAR holds up to 32,672 bytes, CHAR up to 255 and DECIMAL up to 31 digits; wider columns need an override. Text with no length and JSON land as CLOB.
  • The JDBC driver (jcc) ships separately under IBM’s licence.

FAQ

Common questions

What does PostgreSQL boolean map to in MySQL?
TINYINT(1): 0 for false and 1 for true. MySQL accepts other small integers in the same column, so add a CHECK if that matters.
What does PostgreSQL jsonb map to in SQL Server?
NVARCHAR(MAX), which SQL Server’s JSON functions can read. SQL Server 2025 also has a native json type.
What happens to PostgreSQL arrays in other databases?
They land as text. MySQL, SQL Server, Oracle and Db2 have no array column type, so the data is usually split into a child table afterwards.