SQL INSERT Generator
Turn pasted rows or a local delimited file into reviewable SQL INSERT statements with dialect-aware identifiers, literal handling, and row checks.{{ summaryTitle }}
{{ summaryLine }}
{{ sqlScript }}
The chart renderer is unavailable. Literal counts remain available in the column audit.
| Row | Status | Cells | Review note | Statement preview | Copy |
|---|---|---|---|---|---|
| {{ row.row }} | {{ row.status }} | {{ row.cells }} | {{ row.note }} | {{ row.preview }} |
| Column | SQL identifier | Filled | Blank | Literal types | Sample | Copy |
|---|---|---|---|---|---|---|
| {{ row.column }} | {{ row.identifier }} | {{ row.filled }} | {{ row.blank }} | {{ row.types }} | {{ row.sample }} |
Turning a flat set of records into database rows is mainly an alignment problem. Every value must land under the intended column, every identifier must be valid for the destination database, and every literal must keep its original meaning. A script can be valid SQL and still put data in the wrong place.
An INSERT statement pairs an ordered column list with one or more ordered value tuples. The first value belongs to the first column, the second value to the second column, and so on. Headers, delimiters, embedded commas, quoted line breaks, and blank cells all affect that alignment before SQL syntax is produced.
- Identifier
- A schema, table, or column name. Its quoting marks depend on the SQL dialect.
- Literal
- A value written into SQL, such as a quoted string, number, Boolean value, or
NULL. - Delimited record
- A source row split into fields by a comma, tab, semicolon, or pipe while respecting quoted fields.
Text that resembles another data type needs special care. Product codes, postal codes, and account numbers may contain only digits but still belong in text columns. Blank cells also need an explicit policy because an empty string is a real string value, while NULL represents a missing or unknown value.
Generated statements do not know the destination schema, constraints, triggers, permissions, or current rows. Review the column order and literals, then test the script inside a transaction or a disposable database. Application code should still use parameterized queries for untrusted runtime values rather than building SQL strings.
How to Use This Tool:
Start with the destination table and the exact record shape that table expects.
- Paste Source rows or choose a local CSV or text file. Keep the source below 2 MB and select a delimiter when automatic detection would be ambiguous.
- Enter the Table name, choose the target SQL dialect, and either supply Columns in destination order or use the first source row as the column list.
- Choose Value typing, the Blank cells policy, and one statement per row or one multi-row statement. Use text mode when numeric-looking values must remain text.
- Read Row review and Column audit before copying the SQL. Fix shifted row widths, duplicate column renames, unsafe unquoted identifiers, or unexpected literal types before execution.
Interpreting Results:
The statement count describes the generated script, not rows already written to a database. In one-per-row mode it normally matches the source row count; multi-row mode produces one statement, with Oracle using an INSERT ALL block.
- A Ready row has the same number of source cells as active columns. It does not prove that database types or constraints will accept those values.
- A Review row identifies missing cells filled by the blank policy or extra cells omitted from the tuple.
- The literal profile is a quick check for accidental type inference. Compare it with the destination schema, especially for identifiers that contain leading zeros.
Technical Details:
Delimited input must be parsed before it can be quoted as SQL. The transformation keeps quoted delimiters and line breaks inside their field, establishes one column order, maps every row to that order, and only then renders dialect-specific syntax.
Transformation Core:
| Stage | Exact behavior | Review consequence |
|---|---|---|
| Delimiter resolution | A fixed comma, tab, semicolon, or pipe is used, or the first 20 non-empty lines are scored for a consistent delimiter outside quoted fields. | Pin the delimiter when several characters occur regularly. |
| Record parsing | Double-quoted fields may contain delimiters or line breaks; a doubled quote becomes one quote. An unclosed quoted field is retained and warned. | Inspect the affected record before trusting later rows. |
| Column selection | Columns come from a comma-separated list or the first parsed row. Duplicate names receive _2, _3, and later suffixes. | Confirm that renamed columns really exist at the destination. |
| Row alignment | Missing trailing cells become NULL or empty strings according to policy; extra cells are ignored. | Any width difference becomes a row-review note. |
| Literal rendering | Values become strings, numbers, Booleans, NULL, or empty strings under the rules below. | Compare inferred types with column semantics. |
| Statement rendering | Each tuple becomes its own INSERT, or tuples are combined into one multi-row statement. Oracle multi-row output uses INSERT ALL and SELECT 1 FROM DUAL. | Run the final dialect output only in its intended database. |
Identifiers and values use different quoting rules. Identifier quoting protects names such as reserved words or names containing spaces; string quoting protects literal text.
| Selected dialect | Identifier form | Escaped closing mark |
|---|---|---|
| MySQL and BigQuery | `identifier` | A backtick is doubled. |
| SQL Server | [identifier] | A closing bracket is doubled. |
| PostgreSQL, SQLite, Oracle, Snowflake, and ANSI SQL | "identifier" | A double quote is doubled. |
| Source value | Infer mode | Text mode |
|---|---|---|
Case-insensitive NULL | NULL | NULL |
| Blank or missing cell | NULL or '', according to the blank policy | |
true or false | TRUE/FALSE, except SQLite, SQL Server, and Oracle emit 1/0 | Quoted text |
| Recognized integer, decimal, or exponent form | Unquoted numeric literal | Quoted text |
| Other text | Single-quoted text with embedded apostrophes doubled | |
The generated text is deterministic for the same source and settings. It does not connect to the database, inspect column types, validate foreign keys, detect duplicate keys, or add conflict-handling clauses. Those checks belong in the destination database and deployment workflow.
Privacy Notes:
Rows and local files are processed in the browser for generation and are not uploaded by this tool. Database extracts can still contain personal or confidential data, so review what you paste, protect downloaded scripts, and clear shared clipboards or browser sessions when the work is finished.
Worked Examples:
A quoted comma stays in one field
With columns id, name, the source row 3,"Chen, Mei" produces two values rather than three. The name becomes 'Chen, Mei', and the row remains ready because its cell count matches the two columns.
A short row is held for review
If five columns are active but a row supplies four cells, the final value follows the blank policy. The script is still generated, but Row review reports the missing cell so the omission is not mistaken for a complete record.
References:
- RFC 4180: Common Format and MIME Type for CSV Files, Internet Engineering Task Force, October 2005.
- PostgreSQL INSERT documentation, PostgreSQL Global Development Group.
- SQL Injection Prevention Cheat Sheet, OWASP Foundation.
- How to import an SQL file into a database with phpMyAdmin, Simplified Guide.