CSV to SQL Converter
Convert CSV into a CREATE TABLE and INSERT statements for PostgreSQL, MySQL, SQLite, SQL Server, or ANSI SQL.
Paste CSV with a header row on the left.
Apa itu CSV to SQL Converter?
CSV to SQL Converter turns a CSV file's header and rows into ready-to-run SQL statements: a CREATE TABLE with inferred column types, followed by INSERT statements carrying the data. Point it at an export from a spreadsheet, a database dump, or an API, and it infers each column's type from the values actually present — whole numbers become INTEGER, decimals become a floating type, true/false become BOOLEAN, and anything else (or a mixed column) stays TEXT, always the safe fallback. Output is dialect-aware: PostgreSQL, MySQL, SQLite, SQL Server, and ANSI SQL each get correct identifier quoting (double quotes, backticks, or square brackets) and their own type names and boolean literal conventions, so the generated SQL runs without hand-editing.
Cara menggunakan CSV to SQL Converter
- Paste CSV with a header row into the input box on the left.
- Set the table name, pick a SQL dialect, and choose the delimiter your CSV actually uses.
- Toggle Include CREATE TABLE on to get a full schema, or off for INSERT statements only against an existing table.
- Choose how many rows go into each INSERT — one per statement, or batched (10/50/100) for faster bulk loads.
- Copy the generated SQL from the right and run it against your database.
Contoh
Basic table with inferred types
Input: id,name,active 1,Ada,true 2,Alan,false
Output: CREATE TABLE "users" ( "id" INTEGER, "name" TEXT, "active" BOOLEAN ); INSERT INTO "users" ("id", "name", "active") VALUES (1, 'Ada', TRUE); INSERT INTO "users" ("id", "name", "active") VALUES (2, 'Alan', FALSE);
Batched INSERT (10 rows per statement)
Input: id,name 1,Ada 2,Alan
Output: INSERT INTO "users" ("id", "name") VALUES (1, 'Ada'), (2, 'Alan');
Kesalahan umum
- Running the generated INSERT statements against a table whose columns don't match the CSV header order — the column list in each INSERT is explicit, but the target table must actually have those column names.
- Leaving Include CREATE TABLE on when inserting into a table that already exists — this produces a duplicate-table error; turn it off for INSERT-only output.
- Picking the wrong dialect for identifier quoting — running MySQL backtick-quoted SQL against PostgreSQL (or vice versa) is a syntax error.
- Assuming inferred BOOLEAN/INTEGER types match your database's actual schema exactly — review the generated CREATE TABLE before running it against production data.
Mengapa menggunakan alat ini
- Infers INTEGER, floating-point, BOOLEAN, or TEXT per column from the actual CSV values, not a guess from the header name.
- Five dialects (PostgreSQL, MySQL, SQLite, SQL Server, ANSI SQL) with correct identifier quoting and type names for each.
- RFC 4180-compliant CSV parsing, including quoted fields with embedded delimiters or newlines.
- Adjustable INSERT batching for either maximum portability (one row each) or faster bulk loads (many rows per statement).
- Runs entirely in your browser — the CSV data never leaves your machine.