CSV to SQL inserts
Generate CREATE TABLE and INSERT statements from a CSV file
How to use it
- Paste your CSV or open a file.
- Type the table name and pick your database flavor.
- Copy the SQL or download it, then run it in your database.
Questions
How are column types chosen?
Every value in a column is looked at. If all are whole numbers the column is an integer (BIGINT when some are large), if all are numbers with decimals it is NUMERIC or DECIMAL, true/false gives a boolean, dates and timestamps in ISO form (2024-03-31) give DATE and TIMESTAMP, and anything else is text. Values like 007 or 1e5 make the column text so they are not changed.
What happens to empty rows?
A row with nothing in any cell, such as a blank line or a line of commas, is skipped, so it does not insert a row of NULLs. The message above the result says how many were skipped.
Is the SQL safe against odd characters?
Quotes in values are doubled, and MySQL backslashes are escaped. Names are quoted the way each database expects. Only data goes in values; it is never run as part of the statement.
Which databases does it support?
PostgreSQL and SQLite (standard SQL), MySQL and MariaDB, and SQL Server. The standard output has been run in SQLite to check it; the MySQL and SQL Server flavors follow those databases' documented syntax.
Is my data uploaded anywhere?
No. The conversion runs in your browser. Your text is not sent to a server.
Is my text sent to a server?
No. Everything happens in your browser. Your text is not uploaded or stored.
Is it free?
Yes, you can use it for free. A subscription removes limits and unlocks premium tools.