Skip to content

Converting

Types in each database

The SQL type IntoSQL gives each kind of value in PostgreSQL, MySQL, MariaDB, SQLite, SQL Server and Oracle, and when it picks each one.

View as Markdown

IntoSQL reads every value in a column before it decides the column's type, then picks the narrowest type the database has that holds them all. A column of 0 and 1 with sí and no is a boolean, a column of codes like 00127 stays text, and decimals keep their exact digits.

Sizes come from the data: varchar(n) is as long as the longest value, and numeric(p,s) has as many digits and decimal places as the widest number. When a row of values wouldn't fit a type's limit, the next type in the list takes over. The tables below come from the engine's own type map, in the order it tries them.

Note: A column's type can always be overridden: keep it as text in the converter, with --text on the command line, or with as_text in the conversion spec.

PostgreSQL

Value Type When
Yes and no boolean Otherwise
Whole numbers integer Otherwise
Large whole numbers bigint Otherwise
Decimals numeric(p,s) Otherwise
Floating-point numbers double precision Otherwise
Dates date Otherwise
Times of day time Otherwise
Dates with a time timestamp Otherwise
Dates with a time and offset timestamptz Otherwise
Text text Otherwise

MySQL

Value Type When
Yes and no tinyint(1) Otherwise
Whole numbers int Otherwise
Large whole numbers bigint Otherwise
Decimals decimal(p,s) Up to 30 decimal places
Decimals double Otherwise
Floating-point numbers double Otherwise
Dates date Otherwise
Times of day time(6) When values carry fractions of a second
Times of day time Otherwise
Dates with a time datetime(6) When values carry fractions of a second
Dates with a time datetime Otherwise
Dates with a time and offset datetime(6) When values carry fractions of a second
Dates with a time and offset datetime Otherwise
Text varchar(n) Up to 255 characters, while the row stays within the table's row size
Text text Up to 65,535 bytes
Text mediumtext Up to 16,777,215 bytes
Text longtext Otherwise

MariaDB

Value Type When
Yes and no tinyint(1) Otherwise
Whole numbers int Otherwise
Large whole numbers bigint Otherwise
Decimals decimal(p,s) Up to 30 decimal places
Decimals double Otherwise
Floating-point numbers double Otherwise
Dates date Otherwise
Times of day time(6) When values carry fractions of a second
Times of day time Otherwise
Dates with a time datetime(6) When values carry fractions of a second
Dates with a time datetime Otherwise
Dates with a time and offset datetime(6) When values carry fractions of a second
Dates with a time and offset datetime Otherwise
Text varchar(n) Up to 255 characters, while the row stays within the table's row size
Text text Up to 65,535 bytes
Text mediumtext Up to 16,777,215 bytes
Text longtext Otherwise

SQLite

Value Type When
Yes and no BOOLEAN Otherwise
Whole numbers INTEGER Otherwise
Large whole numbers INTEGER Otherwise
Decimals NUMERIC(p,s) Up to 15 digits
Decimals TEXT Otherwise
Floating-point numbers REAL Otherwise
Dates DATE Otherwise
Times of day TIME Otherwise
Dates with a time DATETIME Otherwise
Dates with a time and offset DATETIME Otherwise
Text TEXT Otherwise

SQL Server

Value Type When
Yes and no bit Otherwise
Whole numbers int Otherwise
Large whole numbers bigint Otherwise
Decimals decimal(p,s) Otherwise
Floating-point numbers float Otherwise
Dates date Otherwise
Times of day time Otherwise
Dates with a time datetime2 Otherwise
Dates with a time and offset datetimeoffset Otherwise
Text nvarchar(n) Up to 4,000 characters
Text nvarchar(max) Otherwise

Oracle

Value Type When
Yes and no NUMBER(1) Otherwise
Whole numbers NUMBER(10) Otherwise
Large whole numbers NUMBER(19) Otherwise
Decimals NUMBER(p,s) Otherwise
Floating-point numbers BINARY_DOUBLE Otherwise
Dates DATE Otherwise
Times of day INTERVAL DAY(0) TO SECOND Otherwise
Dates with a time TIMESTAMP Otherwise
Dates with a time and offset TIMESTAMP WITH TIME ZONE Otherwise
Text VARCHAR2(n CHAR) Up to 4,000 bytes
Text CLOB Otherwise