CSV to SQL Converter
Load a spreadsheet into a database with generated SQL.
CSV
SQL
About the CSV to SQL converter
Getting a spreadsheet into a database usually means fighting an import wizard. This converter skips it: paste the CSV, get SQL, run it.
The header row becomes your column names, and column types are inferred from the values below them.
When to use this instead of COPY or LOAD DATA
Native bulk loaders are faster for large files and should be your choice for anything above a few thousand rows. Generated INSERTs win when you want the data checked into a repository as a seed file, or when you cannot get the CSV onto the database server in the first place.
Types come from a sample
A column of digits is typed as an integer. That is right for counts and wrong for postal codes and phone numbers, which lose leading zeros. Scan the CREATE TABLE before running it and widen anything that should be text.
Frequently asked questions
Are quoted fields with commas handled?
Yes. The CSV parser follows RFC 4180, so quoted fields containing commas, quotes and newlines stay in one column.
Can I skip the CREATE TABLE?
Yes, turn the option off when the table already exists.