Skip to content

Db2 data type reference

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

Every Db2 for Linux, UNIX and Windows column type we map, what it becomes in each target database, and what to check.

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

Db2 to each target: testing status
Db2 → PostgreSQLInitial load tested; ongoing change capture not yet
Db2 → MySQLSupported, not yet tested
Db2 → SQL ServerSupported, not yet tested
Db2 → OracleSupported, not yet tested
Db2 → Db2Supported, not yet tested

Numbers

  • smallint

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

    Fits every target.

  • integer

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

    Fits every target.

  • bigint

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

    Fits every target.

  • decimal(p,s), numeric(p,s)

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

    Precision and scale are kept.

  • decfloat

    PostgreSQL
    NUMERIC(34, 0)
    MySQL
    DECIMAL(34, 0)
    SQL Server
    DECIMAL(34, 0)
    Oracle
    NUMBER(34, 0)
    Db2
    Same type

    The driver reports DECFLOAT’s precision (16 or 34) with scale 0, so the default rounds away every fraction. Override it: unbounded NUMERIC on PostgreSQL, or a DECIMAL with a scale elsewhere. Special values (NaN, Infinity) fit only unbounded NUMERIC on PostgreSQL 14 or later.

  • real

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

    4-byte floating point.

  • double, float

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

    8-byte floating point.

Text

  • char(n), graphic(n)

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

    Padded with spaces. CHAR(n) FOR BIT DATA is a different type to the platform: it lands as text and is flagged for review, and should be overridden to a binary type.

  • varchar(n), vargraphic(n)

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

    Db2 counts bytes in VARCHAR; PostgreSQL counts characters, so the same n fits.

  • clob, dbclob

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

    CLOB values can exceed PostgreSQL TEXT’s 1 GB per value.

  • xml

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

    Lands as text.

Dates, times and binary

  • date

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

    Same meaning except on Oracle, whose DATE also carries a time.

  • time

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

    Whole seconds in Db2.

  • timestamp(n)

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

    Up to 12 fractional digits in Db2; PostgreSQL and MySQL keep 6, so the rest is rounded.

  • blob, binary(n), varbinary(n)

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

    BLOB values can exceed PostgreSQL BYTEA’s 1 GB per value.

  • rowid

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

    A row identifier generated by Db2; it has no meaning on the target.

Planning a Db2 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 Db2.

01

FOR BIT DATA

CHAR and VARCHAR columns declared FOR BIT DATA hold bytes. They land as text and are flagged for review: override them to a binary type, or the bytes are read as text and changed.

02

Timestamp precision

Db2 timestamps can have 12 fractional digits. PostgreSQL and MySQL keep 6, so compare values after the same rounding.

03

Change capture on Db2

Db2 change capture works through SQL Replication capture tables that must be set up for each table. The initial load needs none of that.

Notes per target

Landing in each database

Into PostgreSQL

  • Unquoted names fold to lower case, and names are cut at 63 bytes. Pick lower-case names that fit before creating the schema.
  • Identity columns land as GENERATED BY DEFAULT AS IDENTITY. Our platform moves each sequence past the current maximum after the load and again at cutover; if you load by hand, use setval, or the first insert collides.
  • Text cannot hold the NUL character (0x00). Find and clean such values before the load.
  • Comparisons are case-sensitive by default. Use citext or a nondeterministic ICU collation where the source compared case-insensitively.

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.

FAQ

Common questions

What does Db2 DECFLOAT map to in PostgreSQL?
By default NUMERIC with DECFLOAT’s precision and a scale of 0, which rounds away fractions. Override it to unbounded NUMERIC, which keeps every digit and, on PostgreSQL 14 or later, NaN and Infinity.
What does Db2 GRAPHIC map to in PostgreSQL?
CHAR(n), and VARGRAPHIC to VARCHAR(n). PostgreSQL stores text in the database encoding, usually UTF-8, so there is no separate double-byte type.