Skip to content

Convert Excel to SQL

Drop your Excel file and pick your database to get a SQL script with CREATE TABLE and INSERT statements. Each column gets a type, and every fix is listed with its row and column.

Your file
xlsxclientes_2024.xlsxSample file, 7 kB
Your database

4 rows converted, 10 fixes, none rejected

Show
The first rows of clientes_2024.xlsx, with each fix marked
Row
500127Peña Muñoz0123403/02/2024sí1.234,50
600128José Ángel0987015/02/2024noN/A
700129Zoë Ortíz4410029/02/2024sí-12,00
800130Ñuño Castañeda0670011/03/2024no980,75
-- Written by IntoSQL for PostgreSQL.

SET client_encoding = 'UTF8';
BEGIN;

CREATE TABLE clientes_2024 (
    no_cliente text NOT NULL,
    nombre text NOT NULL,
    c_p text NOT NULL,
    alta date NOT NULL,
    activo boolean NOT NULL,
    saldo numeric(6,2)
);
COMMENT ON COLUMN clientes_2024.no_cliente IS 'Nº Cliente';
COMMENT ON COLUMN clientes_2024.c_p IS 'C.P.';

INSERT INTO clientes_2024 (no_cliente, nombre, c_p, alta, activo, saldo) VALUES
('00127', 'Peña Muñoz', '01234', '2024-02-03', TRUE, 1234.50),
('00128', 'José Ángel', '09870', '2024-02-15', FALSE, NULL),
('00129', 'Zoë Ortíz', '44100', '2024-02-29', TRUE, -12.00),
('00130', 'Ñuño Castañeda', '06700', '2024-03-11', FALSE, 980.75);

COMMIT;

Fixes

  1. The header is on row 4; the rows above it were left out.
  2. Row 9 ("TOTAL") is a total, so it was left out.
  3. Column "Nº Cliente" is named no_cliente so PostgreSQL reads it without quotes.
  4. Column "C.P." is named c_p so PostgreSQL reads it without quotes.
  5. Leading zeros kept in "Nº Cliente": 00127 stays 00127, stored as text.
  6. Leading zeros kept in "C.P.": 01234 stays 01234, stored as text.
  7. 15/02/2024 proves the dates in "Alta" are day-first, so 03/02/2024 is read as 2024‑02‑03.
  8. "Activo" holds yes and no words (sí, no), stored as boolean.
  9. Numbers in "Saldo" use a decimal comma: 1.234,50 is read as 1234.50.
  10. N/A in "Saldo" read as empty (1 of 4 values).

Your file is converted on this computer and never uploaded.

Other samples:

One Excel file, six databases

The sample above, clientes_2024.xlsx, and the type each of its columns gets in each database.

In the fileFirst valuePostgreSQLMySQLMariaDBSQLiteSQL ServerOracle
Nº Cliente00127textvarchar(8)varchar(8)TEXTnvarchar(8)VARCHAR2(8 CHAR)
NombrePeña Muñoztextvarchar(16)varchar(16)TEXTnvarchar(16)VARCHAR2(16 CHAR)
C.P.01234textvarchar(8)varchar(8)TEXTnvarchar(8)VARCHAR2(8 CHAR)
Alta03/02/2024datedatedateDATEdateDATE
Activosíbooleantinyint(1)tinyint(1)BOOLEANbitNUMBER(1)
Saldo1.234,50numeric(6,2)decimal(6,2)decimal(6,2)NUMERIC(6,2)decimal(6,2)NUMBER(6,2)

Load the script into your database

The download is a plain .sql file. Each database runs it with its own tools.

  • PostgreSQL

    psql -v ON_ERROR_STOP=1 -d mydb -f clientes_2024.postgresql.sql

    ON_ERROR_STOP makes psql stop at the first error. The script runs in one transaction, so a failed load leaves the database as it was.

  • MySQL

    mysql --default-character-set=utf8mb4 mydb < clientes_2024.mysql.sql

    The script sets utf8mb4 itself; the flag makes the client send it the same way, so accents arrive intact.

  • MariaDB

    mariadb --default-character-set=utf8mb4 mydb < clientes_2024.mariadb.sql

    The script sets utf8mb4 itself; the flag makes the client send it the same way, so accents arrive intact.

  • SQLite

    sqlite3 clientes_2024.db < clientes_2024.sqlite.sql

    The database file is created if it doesn't exist. The converter also downloads a ready .sqlite database, with no command at all.

  • SQL Server

    sqlcmd -S localhost -d mydb -f 65001 -i clientes_2024.sql_server.sql

    -f 65001 reads the file as UTF-8, so accents and ñ arrive as written.

  • Oracle

    sqlplus user@//localhost/mydb @clientes_2024.oracle.sql

    The script turns off substitution variables (SET DEFINE OFF), so an ampersand in your data stays an ampersand.

The command line loads files straight into a SQLite database for free. With IntoSQL Pro, it and the desktop app also load into PostgreSQL, MySQL and MariaDB. For SQL Server and Oracle, run the script.

What to know about Excel files and each database

What IntoSQL reads in Excel files

  • The header row is found even when titles or notes sit above it, and a totals row at the end is left out.
  • Dates stored as Excel serial numbers become real dates, in both the 1900 and the 1904 date systems.
  • Codes with leading zeros, like 00127, stay text. When a workbook has several sheets, you pick the sheet.

What to know about each database

  • Pick the database once the file is open: each one gets the types it supports.

How each kind of value is stored in each database

ValuePostgreSQLMySQLMariaDBSQLiteSQL ServerOracle
Yes and nobooleantinyint(1)tinyint(1)BOOLEANbitNUMBER(1)
Whole numbersintegerintintINTEGERintNUMBER(10)
Large whole numbersbigintbigintbigintINTEGERbigintNUMBER(19)
Decimalsnumeric(p,s)decimal(p,s)doubledecimal(p,s)doubleNUMERIC(p,s)TEXTdecimal(p,s)NUMBER(p,s)
Floating-point numbersdouble precisiondoubledoubleREALfloatBINARY_DOUBLE
DatesdatedatedateDATEdateDATE
Times of daytimetime(6)timetime(6)timeTIMEtimeINTERVAL DAY(0) TO SECOND
Dates with a timetimestampdatetime(6)datetimedatetime(6)datetimeDATETIMEdatetime2TIMESTAMP
Dates with a time and offsettimestamptzdatetime(6)datetimedatetime(6)datetimeDATETIMEdatetimeoffsetTIMESTAMP WITH TIME ZONE
Texttextvarchar(n)textmediumtextlongtextvarchar(n)textmediumtextlongtextTEXTnvarchar(n)nvarchar(max)VARCHAR2(n CHAR)CLOB

Questions about Excel to SQL

Not answered here? Write to us from the contact page and a person replies. Contact page

How do I convert Excel to SQL?

Drop your file on the converter at the top of this page and choose your database: PostgreSQL, MySQL, MariaDB, SQLite, SQL Server or Oracle. Each one gets the types it supports. Download the script and run it in your database.

Which sheet of the workbook is converted?

The first visible sheet. When a workbook has more than one, a Sheet option appears, so you can pick another.

Which types does it use in each database?

Each database gets its own: yes and no values are boolean in PostgreSQL, tinyint(1) in MySQL and MariaDB, bit in SQL Server and NUMBER(1) in Oracle. The table on this page lists every kind of value.

Does it keep leading zeros?

Yes. A code such as 00127 stays text in every database, written as '00127', so no zero is lost.

Can it load the data without a script?

Yes. The command line loads into SQLite for free, and with IntoSQL Pro the desktop app and the command line load into PostgreSQL, MySQL and MariaDB. For SQL Server and Oracle, run the script.

How big can the Excel file be?

In the browser, a workbook is read whole, so the limit is the memory the browser gives this page. The desktop app and the command line take workbooks of any size; on an Apple M4 laptop the command line converts a 117 MB workbook of a million rows in about a second.