Works on this device
SQL Data Type Converter
Change a column type from one database engine to another: the nearest type in PostgreSQL, MySQL, SQL Server, Oracle and SQLite, with a warning where values could be lost. Convert the column list of a CREATE TABLE in one step, or write a CAST and see what each engine returns for your value. No SQL is run.
Enter your values
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Fill in the values, then choose Convert.
Your result
How it was worked out
How to use the converter
- Choose a task. One column type in every engine is the first choice.
- Pick the engine the type comes from and type the type as it is written, such as
NVARCHAR(100),DECIMAL(10,2)orVARCHAR2(50 CHAR). - Choose Convert. The table gives the nearest type in each engine and says where values can be lost.
- To convert many columns, choose A column list from one engine to another and paste the lines of your CREATE TABLE. To change a value, choose CAST or CONVERT a value to another type.
Common mappings
| Kind | PostgreSQL | MySQL | SQL Server | Oracle | SQLite |
|---|---|---|---|---|---|
| Whole number (4 bytes) | integer | INT | int | NUMBER(10) | INTEGER |
| Big whole number | bigint | BIGINT | bigint | NUMBER(19) | INTEGER |
| Exact decimal | numeric(p,s) | DECIMAL(p,s) | decimal(p,s) | NUMBER(p,s) | NUMERIC (not exact) |
| Floating point | double precision | DOUBLE | float | BINARY_DOUBLE | REAL |
| Text up to n characters | varchar(n) | VARCHAR(n) | nvarchar(n) | VARCHAR2(n CHAR) | TEXT |
| Long text | text | LONGTEXT | nvarchar(max) | CLOB | TEXT |
| True or false | boolean | BOOLEAN (TINYINT(1)) | bit | BOOLEAN (23ai) | INTEGER |
| Date and time | timestamp | DATETIME | datetime2 | TIMESTAMP | TEXT |
| Date, time and zone | timestamptz | no such type | datetimeoffset | TIMESTAMP WITH TIME ZONE | TEXT |
| UUID | uuid | BINARY(16) | uniqueidentifier | RAW(16) | TEXT |
| JSON | jsonb | JSON | nvarchar(max) + ISJSON check | JSON (21c and later) | TEXT |
Worked examples
One type: SQL Server NVARCHAR(100) is varchar(100) in PostgreSQL, VARCHAR(100) in MySQL, VARCHAR2(100 CHAR) in Oracle and TEXT in SQLite, which does not check the length.
JSON in SQL Server: SQL Server 2019 and 2022 have no JSON type. Keep JSON in nvarchar(max) with CHECK (ISJSON(col) = 1). PostgreSQL has jsonb, MySQL JSON, Oracle JSON from 21c.
CAST of a decimal: CAST(12.75 AS int) is 12 in SQL Server and SQLite, which cut off the decimal part, and 13 in PostgreSQL, MySQL and Oracle, which round.
Text to a number: CAST('12.5' AS int) stops with an error in SQL Server and PostgreSQL, gives 12 with a warning in MySQL, 12 in SQLite and 13 in Oracle.
What a lossy mapping is
- A smaller range: MySQL
TINYINT(-128 to 127) does not fit SQL Servertinyint(0 to 255), sosmallintis given. - Fewer digits: MySQL
DECIMALhas at most 65 digits and SQL Serverdecimal38. - Fewer fraction digits: SQL Server
datetime2(7)keeps 100 nanoseconds; PostgreSQL and MySQL keep microseconds. - A lost time zone: MySQL has no type that keeps the offset of
datetimeoffsetortimestamptz. - A length that counts something else: SQL Server
varchar(n)and OracleVARCHAR2(n BYTE)count bytes, the others count characters.
Other tools for the same subject
- To format dates or read text as a date in SQL, use the SQL Date Format Converter.
- To check whether a text fits VARCHAR(n) in bytes or characters, use the Varchar Byte Length Calculator.
- To see how each engine compares values with NULL, use the SQL Null Comparison Tester.
Limits you should know
- Spatial types, arrays, ranges and user-defined types are not converted.
- In a column list only the types and identity columns change. Defaults, functions and CHECK rules are copied as written.
- CAST results are shown only where the engine documents them; a float is not rounded here to a decimal or turned into text, because engines write floats in different ways.
- No SQL is run. Test the new table and the CAST in your own database version.