Transform data

CSV to SQL

Convert a CSV into CREATE TABLE and INSERT statements, review the suggested types and download the result as a SQL file.

All the processing in this tool happens in your browser. We do not send your data or queries to AprenderSQL.es.

1. Select your CSV

Up to 2 MB · 5,000 rows · 50 columns
Drag a CSV hereor choose it from your device

2. Check how it will be converted

The types are suggestions you can edit

The columns will appear here once the CSV has been read.

Preview

First 10 rows

Choose a CSV to check its columns and values.

3. Generated SQL

If the SQL is over the editor's limit, you can still copy or download it.

How it interprets the data

Suggested types

INTEGER and REAL are suggested only when the values are consistent. Dates, codes with leading zeros and unclear cases are kept as TEXT.

Safe text

Apostrophes are escaped as in standard SQL, and empty cells can become NULL or empty text.

SQL names

Headers are normalised into simple identifiers so the SQL is easy to reuse and review.

Privacy

The file is not uploaded. The browser reads the CSV you choose and generates the SQL locally. The file's contents are not sent to Analytics or AdSense.

Recommended steps before importing a CSV

1. Review the headers

Check that every column has a clear, unique name. The tool normalises the headers into manageable SQL identifiers, but it is worth deciding what each field means before creating a permanent table.

2. Confirm the types

The detected types are a starting point. A number may really be a postcode, an identifier with leading zeros, or a value that needs DECIMAL rather than REAL. Review the suggestions before reusing the CREATE TABLE.

3. Decide how to handle empty values

An empty cell and an empty string do not always mean the same thing. Use NULL when you want to represent a missing value, and keep empty text only when that state means something in your data.

Conversion example

A CSV with columns id,name,price and rows such as 1,Keyboard,49.50 can become a table with an integer id, a text name and a numeric price, followed by INSERT statements. Before importing it into a real project, review primary keys, constraints, decimal precision and business rules: the CSV alone does not contain all that information.

Tip: generate the SQL first, read it and test a small sample. If the target is a production database, then use your engine's recommended import mechanism, with a suitable backup.

Limits, and decisions that cannot be inferred automatically

The tool detects simple formats from the values available, but it does not know what the data set is meant to represent. It cannot decide whether a column should be a PRIMARY KEY, FOREIGN KEY, UNIQUE or NOT NULL, nor whether a piece of text is a date you need to keep with its time zone.

For large files, repeatable migrations or production loads, your engine's native import commands are usually more suitable. This tool is designed for learning, prototypes and small conversions you want to inspect before running them.

Related tools