Skip to main content
KalkuNet

CSV to SQL — CREATE TABLE and INSERT Statements for MySQL, PostgreSQL, SQLite, SQL Server

Generate escaped SQL CREATE TABLE DDL and multi-row INSERT statements from CSV.

Runs in your browserDeveloper · JSON, YAML, TOML, XML & CSV Converters
Delimiter:
Database:

4 rows, 9 columns, 1 INSERT statements, comma delimiter (detected).

ColumnDetected contentSQL typeEmpty cells
idintegerINT0
hostnametextVARCHAR(11)0
iptextVARCHAR(10)0
vlanintegerINT0
lokasitextVARCHAR(12)0
aktiftrue/falseBOOLEAN0
dipasangdateDATE0
daya_wdecimalDECIMAL(5, 2)0
catatantextVARCHAR(22)1
  • Types are inferred from the whole column: integer, decimal, true/false, a YYYY-MM-DD date, or text. Numbers with a leading zero such as 007 stay text so postal codes and IDs do not change.
  • Text is escaped for the database: quotes are doubled (''), MySQL also doubles backslashes, and SQL Server uses N'…' for Unicode. Column names are always quoted (`…`, "…" or […]).

When to use the CSV to SQL CREATE TABLE & Batched INSERT Converter

  • Column types inferred from the data

    Every column is checked in full: integer, decimal with enough precision, true/false, a YYYY-MM-DD date, or text. Numbers with a leading zero such as 007 stay text so postal codes and staff numbers do not change.

  • Escaping for each database

    Single quotes are doubled in every database. MySQL also doubles backslashes, SQL Server uses N'…' for Unicode text, and column names get each database's identifier quotes.

  • Many rows per statement

    Rows are grouped into multi-row INSERT statements, which import far faster than one statement per row. The rows per statement can be set; SQL Server is capped at 1,000 rows per statement.

  • Tested against a real database

    SQLite and PostgreSQL output is run in SQLite and read back, and MySQL and SQL Server output is read with a separate literal reader. Every value, quotes and backslashes included, comes back the same.

Frequently asked questions

What happens to empty cells?

Empty cells in number, date and true/false columns always become NULL; in text columns they can be NULL or an empty string, as you choose.

Can I skip the table definition?

Yes. Turn the option off when the table already exists and only the INSERT statements are written.

What if a column name is empty or repeated?

An empty name becomes column_3 and a repeated name becomes name_2, the same as the CSV to JSON conversion.

Is my data uploaded?

No. The conversion runs entirely in your browser.

Learn more