About the CSV to SQL Converter
Loading a small CSV into a database is often quickest with plain SQL. This converter reads the CSV, infers a column type for each column by looking at every value (INTEGER, DECIMAL, BOOLEAN or a VARCHAR sized to the longest value), and writes a CREATE TABLE followed by INSERT statements. Multi-row inserts are batched 500 rows at a time, which is fast on every engine; untick the option for one statement per row if your tool needs that.
Identifier quoting differs by database: double quotes for PostgreSQL and SQLite, backticks for MySQL and MariaDB, square brackets for SQL Server. Pick the one you need and the table and column names are quoted accordingly. Column names with spaces or punctuation are converted to underscores. String values have single quotes doubled, empty cells become NULL, and numeric-looking values are written bare.
The type inference is a starting point; adjust lengths or switch to TEXT before running the script on production. For loading millions of rows, your database's bulk loader (COPY, LOAD DATA, bcp) is the better route.
How to use
- Paste or upload the CSV and set the table name.
- Choose the identifier quoting for your database.
- Copy the SQL into your client and run it, checking the inferred types first.
Common questions
- Which databases does the output work on?
- MySQL, MariaDB, PostgreSQL, SQLite and SQL Server, as long as you choose the matching identifier quotes. The INSERT syntax is standard.
- How are dates handled?
- As strings in quotes, which every database will cast on insert if the column is a date type. The inferred type is VARCHAR; change it to DATE if needed.
- Does it escape quotes in values?
- Yes, single quotes inside values are doubled, which is the SQL standard.
- What about very large files?
- The tool handles tens of thousands of rows. For more, use your database's bulk import.