How to use the CSV → SQL INSERT / UPSERT Generator
Convert a CSV (or pasted spreadsheet) into dialect-aware INSERT, UPSERT, or MERGE statements ready for PostgreSQL, MySQL, SQL Server (T-SQL), SQLite, BigQuery, or Snowflake. Generate a starter CREATE TABLE with inferred types, batch large loads, wrap in transactions, and review the script before running it against your database. Nothing connects to a database and nothing is uploaded — generation is fully local.
What it does
- Generates INSERT statements (single-row, multi-row, or bulk).
- Generates UPSERT / ON CONFLICT (PostgreSQL, SQLite), INSERT ON DUPLICATE KEY UPDATE (MySQL), and MERGE (SQL Server, Oracle, BigQuery, Snowflake).
- Generates a starter CREATE TABLE with inferred types (INT, BIGINT, NUMERIC, BOOLEAN, TIMESTAMP, TEXT).
- Per-column type overrides, column renames, and exclude lists.
- Validation report: duplicate keys, blank headers, leading-zero IDs, NULL handling, escaping issues.
- Batching: split large output into smaller chunks; wrap in
BEGIN; ... COMMIT; transactions.
- Dialect-correct quoting and identifier handling for PostgreSQL, MySQL, T-SQL, SQLite, BigQuery, Snowflake.
When to use it
- Load spreadsheet data into a staging or QA database without writing the SQL by hand.
- Build seed data scripts for tests or local environments.
- Generate UPSERT SQL keyed on
id or email for an idempotent reload.
- Migrate a flat file into a normalized table using a generated
CREATE TABLE as a starting point.
- Produce a reviewable change script for a DBA to run.
- Prepare a backfill batch with explicit transaction boundaries.
How to use it
- Paste your CSV including the header row (or load from file).
- Pick the SQL dialect (PostgreSQL, MySQL, T-SQL, SQLite, BigQuery, Snowflake).
- Set the target table name and choose the generation mode: INSERT, UPSERT/ON CONFLICT, or MERGE.
- For UPSERT / MERGE, specify the unique key columns.
- Open Preview / Columns to override SQL types, rename columns, or exclude columns.
- Use Batching / Transactions to split very large outputs and add a wrapping transaction.
- Open the Validation Report tab to fix duplicate keys, blank headers, and escaping issues before you run.
- Copy or download the generated SQL and review it before applying.
Tips & pitfalls
- UPSERT / MERGE requires a real unique or primary key constraint in your database — duplicate keys inside the CSV will repeat updates or break the MERGE.
- NULL handling: empty CSV cells can become empty strings or
NULL — choose explicitly per column.
- Leading-zero IDs (
007) lose their zeros when treated as integers; the validation report flags these so you can keep them as TEXT.
- Boolean inference from
true / false / 1 / 0 varies by dialect — override the column type when in doubt.
- For very large datasets, prefer COPY (PostgreSQL) or LOAD DATA (MySQL) over generated INSERTs.
- The tool never connects to a database. The generated SQL is a script for you to review and run.
FAQ
- How do I convert CSV to SQL INSERT statements? Paste the CSV with a header row, choose your dialect and table name, and copy the generated INSERT script.
- How do I generate UPSERT SQL? Switch the mode to UPSERT / ON CONFLICT and specify the unique key columns. The tool emits the right syntax for your dialect.
- Does it support MERGE statements? Yes — for SQL Server (T-SQL), Oracle, BigQuery, and Snowflake, with key columns and matched / not-matched clauses.
- Can I generate CREATE TABLE from CSV? Yes — the generator infers column types from the data and produces a starter
CREATE TABLE you can refine.
- Does it execute SQL against my database? No — the tool never connects to a database. It only generates a script for review and manual execution.
- Is my CSV uploaded? No. All generation runs in your browser.
- How does it handle dates and timestamps? ISO 8601 strings (
2026-01-15T10:30:00Z) are inferred as TIMESTAMP; ambiguous formats are kept as TEXT — override per column if needed.
Runs locally in your browser. No uploads. The tool generates SQL scripts but never connects to or executes against a database.