Skip to content

CSV to SQL

Generates CREATE TABLE and INSERT statements from a table, with inferred types and a chosen dialect.

Turns a table into CREATE TABLE and INSERT statements for PostgreSQL, MySQL, SQLite or SQL Server, with the column types inferred from the data. It shows the columns as they will be created before it writes anything, which is where you catch a numeric column that came in as text.

🔒 Runs entirely in your browsersqlcsvconvertdatabase

Drop the CSV you want as SQL

Read in this tab. Nothing is uploaded. Files from Korean, Japanese, Chinese and Western Excel (CP949, Shift_JIS, GBK, Windows-1252) are recognised.

How to use it

  1. Pick the dialect

    It decides the quoting style, the auto-increment syntax and the text type. SQL Server gets NVARCHAR rather than VARCHAR, which is the difference between storing 한글 and storing question marks.

  2. Check the inferred types

    The table above the SQL shows each column, the identifier it will get, its type and whether it is nullable. A column you expected to be INTEGER showing as TEXT means a stray value is in it.

  3. Set the batch size

    A hundred rows per INSERT is a good default. One per row is easier to debug and much slower to run.

Common questions

Why is every identifier quoted?

Because a column called order, group or desc is a reserved word, and quoting only when necessary means getting the list of reserved words right for four dialects. Quoting unconditionally is boring and always works.

Are Korean column names safe?

In all four dialects when quoted, yes. If your server refuses them anyway, the ASCII-only option transliterates the identifiers while leaving the data alone.

What happens to quotes inside my data?

They are doubled, which is the SQL standard escape. For MySQL backslashes are doubled too, because MySQL alone treats a backslash as an escape inside a literal — without that, C:\temp arrives in the database with a tab in it.

Empty cell or NULL?

Your choice, and it matters: in SQL an empty string is a value and NULL is the absence of one, and they behave differently in comparisons, in COUNT and in a unique index. NULL is the default.

Feed it from

Next

These accept what this tool produces, so the result can go straight in.