MySQL data type reference
MySQL to PostgreSQL, SQL Server, Oracle and Db2: data type mapping
Every MySQL column type we map, what it becomes in each target database, and where MySQL’s defaults differ from the rest.
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 MySQL 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.
| MySQL → PostgreSQL | Tested with live change capture on MySQL 8 (Nov 2026) |
|---|---|
| MySQL → MySQL | Supported, not yet tested |
| MySQL → SQL Server | Supported, not yet tested |
| MySQL → Oracle | Supported, not yet tested |
| MySQL → Db2 | Supported, not yet tested |
Numbers
tinyint, smallint, year
- PostgreSQL
- SMALLINT
- MySQL
- Same type
- SQL Server
- SMALLINT
- Oracle
- NUMBER(5)
- Db2
- SMALLINT
YEAR lands as a small integer. tinyint(1) used as a boolean lands as SMALLINT; override it to BOOLEAN where it means true or false.
mediumint, int
- PostgreSQL
- INTEGER
- MySQL
- Same type
- SQL Server
- INT
- Oracle
- NUMBER(10)
- Db2
- INTEGER
Same signed range as the 4-byte integer elsewhere.
bigint
- PostgreSQL
- BIGINT
- MySQL
- Same type
- SQL Server
- BIGINT
- Oracle
- NUMBER(19)
- Db2
- BIGINT
Fits every target.
tinyint unsigned, smallint unsigned
- PostgreSQL
- INTEGER
- MySQL
- Same type
- SQL Server
- INT
- Oracle
- NUMBER(10)
- Db2
- INTEGER
Widened one size so the unsigned maximum fits.
int unsigned, mediumint unsigned
- PostgreSQL
- BIGINT
- MySQL
- Same type
- SQL Server
- BIGINT
- Oracle
- NUMBER(19)
- Db2
- BIGINT
Widened: int unsigned reaches 4.29 billion, past a signed 4-byte integer.
bigint unsigned
- PostgreSQL
- NUMERIC(20, 0)
- MySQL
- Same type
- SQL Server
- DECIMAL(20, 0)
- Oracle
- NUMBER(20, 0)
- Db2
- DECIMAL(20, 0)
No signed 8-byte integer holds the unsigned maximum, so it becomes a 20-digit number.
decimal(p,s), numeric(p,s)
- PostgreSQL
- NUMERIC(p, s)
- MySQL
- Same type
- SQL Server
- DECIMAL(p, s)
- Oracle
- NUMBER(p, s)
- Db2
- DECIMAL(p, s)
Precision and scale are kept.
float
- PostgreSQL
- REAL
- MySQL
- Same type
- SQL Server
- REAL
- Oracle
- BINARY_FLOAT
- Db2
- REAL
4-byte floating point.
double
- PostgreSQL
- DOUBLE PRECISION
- MySQL
- Same type
- SQL Server
- FLOAT
- Oracle
- BINARY_DOUBLE
- Db2
- DOUBLE
8-byte floating point.
bit(1)
- PostgreSQL
- BOOLEAN
- MySQL
- Same type
- SQL Server
- BIT
- Oracle
- NUMBER(1)
- Db2
- SMALLINT
A real boolean on PostgreSQL. BOOL and BOOLEAN are aliases of tinyint(1) in MySQL, so those columns land as SMALLINT (see above). A bit(n) wider than 1 is a bit field, not a flag: override it.
Text
char(n)
- PostgreSQL
- CHAR(n)
- MySQL
- Same type
- SQL Server
- NCHAR(n)
- Oracle
- CHAR(n)
- Db2
- CHAR(n)
MySQL strips trailing spaces from CHAR on read; PostgreSQL CHAR keeps the padding.
varchar(n)
- PostgreSQL
- VARCHAR(n)
- MySQL
- Same type
- SQL Server
- NVARCHAR(n)
- Oracle
- VARCHAR2(n)
- Db2
- VARCHAR(n)
Counts characters, as PostgreSQL does. Default MySQL collations (utf8mb4_0900_ai_ci) ignore case and accents; PostgreSQL does not.
tinytext, text, mediumtext, longtext
- PostgreSQL
- TEXT
- MySQL
- Same type
- SQL Server
- NVARCHAR(MAX)
- Oracle
- CLOB
- Db2
- CLOB
longtext allows 4 GB; PostgreSQL TEXT caps a value at 1 GB.
enum, set
- PostgreSQL
- TEXT
- MySQL
- Same type
- SQL Server
- NVARCHAR(MAX)
- Oracle
- CLOB
- Db2
- CLOB
Lands as text, so the allowed values are no longer enforced. For ENUM add a CHECK constraint or a PostgreSQL enum type; SET holds several values, so an array or a child table fits it better.
json
- PostgreSQL
- JSONB
- MySQL
- Same type
- SQL Server
- NVARCHAR(MAX)
- Oracle
- CLOB
- Db2
- CLOB
Lands as JSONB on PostgreSQL. Indexes on JSON paths (generated columns in MySQL) need recreating as GIN or expression indexes.
Dates and times
date
- PostgreSQL
- DATE
- MySQL
- Same type
- SQL Server
- DATE
- Oracle
- DATE
- Db2
- DATE
Zero dates such as 0000-00-00 are invalid everywhere else. Find them first and turn them into NULL or a real date.
time
- PostgreSQL
- TIME(6)
- MySQL
- Same type
- SQL Server
- TIME
- Oracle
- TIMESTAMP
- Db2
- TIME
MySQL TIME is a duration from -838:59:59 to 838:59:59. Values outside 00:00–24:00 do not fit a PostgreSQL TIME; use INTERVAL for those columns.
datetime
- PostgreSQL
- TIMESTAMP(6)
- MySQL
- Same type
- SQL Server
- DATETIME2
- Oracle
- TIMESTAMP
- Db2
- TIMESTAMP
No time zone, as on the target.
timestamp
- PostgreSQL
- TIMESTAMP(6)
- MySQL
- Same type
- SQL Server
- DATETIME2
- Oracle
- TIMESTAMP
- Db2
- TIMESTAMP
MySQL stores TIMESTAMP in UTC and shows it in the session time zone. Fix the session time zone during the load, or values shift by the offset; consider TIMESTAMPTZ on PostgreSQL.
Binary and spatial
binary(n), varbinary(n), tinyblob, blob, mediumblob, longblob
- PostgreSQL
- BYTEA
- MySQL
- Same type
- SQL Server
- VARBINARY(MAX)
- Oracle
- BLOB
- Db2
- BLOB
binary(n) is padded with zero bytes. longblob allows 4 GB; PostgreSQL BYTEA caps a value at 1 GB.
geometry, point, linestring, polygon and the multi- types
- PostgreSQL
- BYTEA
- MySQL
- Same type
- SQL Server
- VARBINARY(MAX)
- Oracle
- BLOB
- Db2
- BLOB
Lands as binary (MySQL’s 4-byte SRID followed by WKB), so spatial queries and indexes do not carry over. Use PostGIS on PostgreSQL to query it again.
Planning a MySQL migration? We can map your schema and run the move with change data capture.
Database migration servicesBeyond types
What a type table does not show
The schema can convert cleanly and the application still break. These are the usual reasons with MySQL.
01
Zero dates and sql_mode
Older MySQL data can hold 0000-00-00 dates and other values strict mode would reject. Find them before the load; every other target refuses them.
02
AUTO_INCREMENT
AUTO_INCREMENT columns become identity columns. On PostgreSQL our platform moves each sequence past the current maximum after the load and at cutover; on other targets, reset it yourself.
03
Collations
MySQL’s default utf8mb4_0900_ai_ci compares case- and accent-insensitively. PostgreSQL compares exactly unless you choose citext or a nondeterministic ICU collation.
04
Backticks and names
MySQL quotes names with backticks and keeps their case on most file systems. PostgreSQL uses double quotes and folds unquoted names to lower case.
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 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
- How do MySQL unsigned integers map to PostgreSQL?
- They widen one size so the unsigned maximum fits: int unsigned becomes BIGINT, and bigint unsigned becomes NUMERIC(20,0), because no signed 8-byte integer holds its maximum.
- What does MySQL TIMESTAMP map to in PostgreSQL?
- TIMESTAMP(6). MySQL stores TIMESTAMP in UTC and shows it in the session time zone, so fix the session time zone during the load, or choose TIMESTAMPTZ.
- What does MySQL DATETIME map to in SQL Server?
- DATETIME2, which keeps up to 100 ns and has the same range from year 1 to 9999, so values fit without rounding.
- What happens to MySQL ENUM columns in PostgreSQL?
- They land as TEXT, so the allowed values are no longer enforced. Add a CHECK constraint or create a PostgreSQL enum type if they matter.
Sources and next steps