Skip to content

SQL Server data type reference

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

Every SQL Server column type we map, what it becomes in each target database, and what to check before you trust the result.

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 SQL Server 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.

SQL Server to each target: testing status
SQL Server → PostgreSQLAutomated end-to-end test; a live deployment keeps about 780 million rows in sync ahead of cutover
SQL Server → MySQLTested by hand
SQL Server → SQL ServerSupported, not yet tested
SQL Server → OracleSupported, not yet tested
SQL Server → Db2Supported, not yet tested

Numbers

  • tinyint

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

    Holds 0–255. PostgreSQL, Oracle and Db2 have no 1-byte integer, so it widens to SMALLINT (on MySQL too, in our defaults); add a CHECK if the range matters.

  • smallint

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

    Fits every target.

  • int

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

    Fits every target. An IDENTITY column becomes the target’s identity column; see the notes per target for re-seeding.

  • bigint

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

    Fits every target.

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

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

    Precision and scale are kept, so values do not round.

  • money

    PostgreSQL
    NUMERIC(19, 4)
    MySQL
    DECIMAL(19, 4)
    SQL Server
    Same type
    Oracle
    NUMBER(19, 4)
    Db2
    DECIMAL(19, 4)

    Keeps 4 decimal places. PostgreSQL’s own money type takes its scale and format from lc_monetary (usually 2 places), so it is not used.

  • smallmoney

    PostgreSQL
    NUMERIC(10, 4)
    MySQL
    DECIMAL(10, 4)
    SQL Server
    Same type
    Oracle
    NUMBER(10, 4)
    Db2
    DECIMAL(10, 4)

    As money, with a smaller range.

  • float

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

    SQL Server stores float(1–24) as real, so those columns already report as real.

  • real

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

    4-byte floating point everywhere.

  • bit

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

    Code that compares the column with 1 or 0 must change for PostgreSQL, which rejects boolean = integer.

Text

  • char(n), nchar(n)

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

    Padded with spaces. MySQL and Db2 allow CHAR up to 255; SQL Server NCHAR up to 4,000.

  • varchar(n), nvarchar(n)

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

    nvarchar(n) counts UTF-16 code units, so the same n always fits a target that counts characters (PostgreSQL, MySQL); Oracle and Db2 count bytes by default. SQL Server ignores trailing spaces when comparing; PostgreSQL VARCHAR and TEXT do not, which changes joins on padded data.

  • varchar(max), nvarchar(max)

    PostgreSQL
    TEXT
    MySQL
    TEXT
    SQL Server
    Same type
    Oracle
    CLOB
    Db2
    CLOB

    (max) holds up to 2 GB; PostgreSQL TEXT caps a single value at 1 GB, and MySQL TEXT holds 64 KB, so override to LONGTEXT for larger values. If the column holds JSON, JSONB is the better home on PostgreSQL.

  • text, ntext

    PostgreSQL
    TEXT
    MySQL
    LONGTEXT
    SQL Server
    Same type
    Oracle
    CLOB
    Db2
    CLOB

    Deprecated in SQL Server.

  • xml

    PostgreSQL
    TEXT
    MySQL
    LONGTEXT
    SQL Server
    Same type
    Oracle
    CLOB
    Db2
    CLOB

    Lands as text. PostgreSQL has an xml type if you query the content with XPath.

  • json (SQL Server 2025)

    PostgreSQL
    TEXT
    MySQL
    TEXT
    SQL Server
    Same type
    Oracle
    CLOB
    Db2
    CLOB

    Not in the default rules yet, so it lands as text. Override it to JSONB on PostgreSQL or JSON on MySQL.

Dates and times

  • date

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

    Same meaning everywhere except Oracle, whose DATE also carries a time of day (set to midnight).

  • time(n)

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

    Up to 100 ns. PostgreSQL keeps microseconds, so the 7th digit is rounded (23:59:59.9999999 becomes 24:00:00). MySQL TIME and Db2 TIME drop the fraction; Oracle adds a date.

  • datetime

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

    Steps of 1/300 s (shown as .000, .003, .007). Read as milliseconds it lands as .003, through datetime2 as .003333: use the same conversion when you compare data.

  • datetime2(n)

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

    datetime2(7) is rounded to microseconds on every other target. Round the source the same way before a row-by-row comparison.

  • smalldatetime

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

    Minute precision, 1900 to 2079; fits everywhere.

  • datetimeoffset(n)

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

    PostgreSQL stores the instant in UTC and drops the original offset; MySQL and Db2 keep no zone at all. Keep the offset in its own column if the application shows the time as entered.

Binary and identifiers

  • binary(n), varbinary(n), varbinary(max)

    PostgreSQL
    BYTEA
    MySQL
    LONGBLOB
    SQL Server
    Same type
    Oracle
    BLOB
    Db2
    BLOB

    binary(n) values arrive padded with zero bytes. varbinary(max) allows 2 GB; PostgreSQL BYTEA caps a value at 1 GB.

  • image

    PostgreSQL
    BYTEA
    MySQL
    LONGBLOB
    SQL Server
    Same type
    Oracle
    BLOB
    Db2
    BLOB

    Deprecated in SQL Server.

  • uniqueidentifier

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

    Move it as text: SQL Server stores the first three groups byte-swapped. SQL Server shows GUIDs in upper case and sorts them by their last six bytes first, so string comparisons and ORDER BY change.

  • rowversion, timestamp

    PostgreSQL
    BYTEA
    MySQL
    LONGBLOB
    SQL Server
    Same type
    Oracle
    BLOB
    Db2
    BLOB

    An 8-byte row version, not a date. No target updates it for you: jobs that read changes with rowversion > last value need a new change marker; for optimistic locking on PostgreSQL, compare xmin for equality or keep a trigger-maintained version column.

Spatial and special types

  • geography, geometry

    PostgreSQL
    TEXT
    MySQL
    LONGBLOB
    SQL Server
    Same type
    Oracle
    BLOB
    Db2
    BLOB

    Spatial queries and indexes do not carry over. On PostgreSQL, install PostGIS and convert to its geography or geometry types if the application runs spatial queries.

  • hierarchyid

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

    Lands as its path string; the driver reports a length of 892, and longer paths need TEXT. As text, '/1/10/' sorts before '/1/2/', so ORDER BY no longer gives depth-first order. PostgreSQL’s ltree extension is the closest replacement, after converting the paths.

  • sql_variant

    PostgreSQL
    TEXT
    MySQL
    LONGTEXT
    SQL Server
    Same type
    Oracle
    CLOB
    Db2
    CLOB

    Lossy: values arrive as text and the type of each value is lost. Split the column if the types matter.

Planning a SQL Server 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 SQL Server.

01

Computed columns

SQL Server change data capture records a computed column as NULL, so a change-capture migration has to re-read those values from the source (Debezium’s reselect post-processor can). On the target they are plain columns. To have PostgreSQL compute them, recreate them as GENERATED ALWAYS AS (…) STORED; the expression must be immutable, so anything using GETDATE() or locale-dependent formatting needs rewriting. PostgreSQL 18 also has virtual generated columns, which cannot be indexed.

02

Case-insensitive comparisons

Most SQL Server databases compare case-insensitively, so 'abc' = 'ABC' and a unique index rejects 'abc' after 'ABC'. PostgreSQL does neither by default. Use citext or a nondeterministic ICU collation; LIKE works with nondeterministic collations only from PostgreSQL 18.

03

String concatenation and defaults

T-SQL joins strings with +; PostgreSQL uses || or concat(). 'a' + NULL and 'a' || NULL are both NULL (with SQL Server’s default CONCAT_NULL_YIELDS_NULL ON), and concat() skips NULLs in both. Defaults such as GETDATE() and NEWID() become now() and gen_random_uuid(); now() is the transaction start time, not the statement time.

04

Long names

SQL Server names can be 128 characters. PostgreSQL keeps 63 bytes and cuts the rest without an error, so long index and constraint names can collide. Shorten them in the target schema.

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

Is PostgreSQL case-sensitive like SQL Server?
No. Most SQL Server databases compare text case-insensitively; PostgreSQL compares it case-sensitively by default. Use the citext type or a nondeterministic ICU collation on columns such as emails and usernames, or compare lower() values with a matching index.
How do I migrate an IDENTITY column to PostgreSQL?
Create it as GENERATED BY DEFAULT AS IDENTITY, load the data, then move each sequence past the current maximum with setval; our platform does this after the load and again at cutover. Without that step the first new insert collides with an existing key.
What does SQL Server nvarchar(max) map to in MySQL?
TEXT by default, which holds only 64 KB. Override it to MEDIUMTEXT or LONGTEXT if the column holds larger values.
What does SQL Server datetime2 map to in PostgreSQL?
TIMESTAMP(6). datetime2(7) keeps 100-nanosecond precision and PostgreSQL keeps microseconds, so the last digit is rounded. Round the source the same way when you compare data after the move.
What replaces a SQL Server uniqueidentifier in PostgreSQL?
The UUID type. Move the values as text, because SQL Server stores the first three groups byte-swapped. PostgreSQL prints UUIDs in lower case and sorts them differently, so check string comparisons and ORDER BY on GUID columns.