CSV to SQL
How to use
Turns a CSV or Excel sheet into SQL CREATE TABLE and INSERT statements. Drop the file, choose your database, and download the .sql script.
Step 1 of 4: Upload
- 1
- 2
- 3
- 4
Step 1 of 4 · Upload
- 1Upload
- 2Options
- 3Convert
- 4Download
- Loading a spreadsheet export into a development database
- Creating seed data for tests from a CSV
- Moving a small dataset between systems without an import wizard
Free and private. Everything runs on your own device, with no account and no uploads.
Getting a spreadsheet into a database usually means either a database-specific import wizard or writing INSERT statements by hand. This converter reads a CSV, TSV or Excel file and writes a plain SQL script: a CREATE TABLE statement with a type chosen for each column, followed by INSERT statements for every row. Paste it into a database console or run it from the command line.
A column becomes BOOLEAN if every value is true or false, INTEGER if every value is a whole number, REAL if every value is numeric, DATE if every value is written YYYY-MM-DD, and TEXT otherwise. Empty cells become NULL and do not affect the choice.
Deliberately. A value with a leading zero, such as 00745, would lose the zero as a number, so any column containing one stays TEXT. The same applies to numbers longer than 18 digits.
They are lowercased, spaces become underscores, other symbols are removed, and a name that would start with a digit gets a prefix. Duplicate names are numbered so every column is unique.
Each non-empty sheet becomes its own table, named after the sheet.
- 1
Add the file
CSV, TSV, XLSX, XLS and ODS are accepted. The first row must contain the column names.
- 2
Pick the quoting style
Double quotes suit PostgreSQL, SQLite and SQL Server; backticks suit MySQL and MariaDB.
- 3
Convert
Column types are inferred, names are cleaned, and rows are written in batches of 500.
- 4
Run the script
Review the CREATE TABLE line first, adjust any type you disagree with, then execute it.
- ·The script has no primary key, indexes or constraints. Add them to the CREATE TABLE line before you run it if the table will be queried.
- ·Rows are batched 500 per INSERT so that each statement stays under default server limits even for large files.