Skip to content
OddsockLocal
Local
Source text
ItemQuantity
Notebook12
Pencil4
3 wordsRuns in this browser. Nothing is uploaded.

How to use

  1. Paste CSV or drop a CSV file. The first row is the header.
  2. Set Table name. It defaults to records.
  3. Read CREATE TABLE. NUMERIC, BOOLEAN or TEXT is chosen from the whole column.
  4. Read the INSERT. Strings are single-quoted, numbers are bare.

What is CSV to SQL?

CSV to SQL reads a table and writes two statements: CREATE TABLE, then a single INSERT with one tuple per row. A two-row sheet Item,Quantity / Notebook,12 / Pen,4 with the table name records becomes CREATE TABLE "records" ("Item" TEXT, "Quantity" NUMERIC); INSERT INTO "records" ("Item", "Quantity") VALUES ('Notebook', 12), ('Pen', 4);. Quantity is NUMERIC because every value in that column is a number. Item is TEXT.

Read more

Column types are inferred per column. All numbers, or null, means NUMERIC. All booleans means BOOLEAN. Anything else is TEXT. Identifiers are double-quoted, which PostgreSQL and SQLite accept as written. MySQL treats double quotes as identifiers only in ANSI_QUOTES mode. There is no dialect menu on this page, so the quoting is that one style.

The JSON to SQL page does not write CREATE TABLE. It only writes the INSERT, from an array of objects. The IN-clause page does not write a table at all.

Use cases

  • A spreadsheet export of two columns should become a table you can create and fill in one paste.
  • Quantity should stay a number, 12, not the string '12', because every cell in the column parsed as numeric.
  • You need the CREATE statement, not only the rows, and the JSON page will not emit it.
  • A column of mixed words and digits should be TEXT so a later numeric cell does not get mis-typed.

Items and quantities, table name records

Table name records. CSV: Item,Quantity then Notebook,12 then Pen,4.

CREATE TABLE "records" ("Item" TEXT, "Quantity" NUMERIC); INSERT INTO "records" ("Item", "Quantity") VALUES ('Notebook', 12), ('Pen', 4);

Why use Oddsock

CREATE TABLE is the part the other SQL pages skip. Types come from the column, not from the first row alone.

Related tools

Using this tool

Every Quantity cell is a number, so the column is NUMERIC. Item contains words, so it is TEXT. One non-numeric cell would make the whole column TEXT.