---
title: "Convert CSV to SQL"
description: "Convert CSV files to SQL for PostgreSQL, MySQL, MariaDB, SQLite, SQL Server or Oracle in your browser. Free, and your file is never uploaded."
canonical: https://intosql.com/csv-to-sql
last_updated: 2026-10-15
---

# Convert CSV to SQL

Drop your CSV file and pick your database to get a SQL script with CREATE TABLE and INSERT statements. Each column gets a type, and every fix is listed with its row and column.

## One CSV file, six databases

The sample above, ventas_2024.csv, and the type each of its columns gets in each database.

| In the file | First value | PostgreSQL | MySQL | MariaDB | SQLite | SQL Server | Oracle |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Folio | `00412` | `text` | `varchar(8)` | `varchar(8)` | `TEXT` | `nvarchar(8)` | `VARCHAR2(8 CHAR)` |
| Cliente | `Peña Muñoz` | `text` | `varchar(16)` | `varchar(16)` | `TEXT` | `nvarchar(16)` | `VARCHAR2(16 CHAR)` |
| Ciudad | `Mérida` | `text` | `varchar(16)` | `varchar(16)` | `TEXT` | `nvarchar(16)` | `VARCHAR2(16 CHAR)` |
| Fecha | `15/02/2024` | `date` | `date` | `date` | `DATE` | `date` | `DATE` |
| Importe | `1.234,50` | `numeric(6,2)` | `decimal(6,2)` | `decimal(6,2)` | `NUMERIC(6,2)` | `decimal(6,2)` | `NUMBER(6,2)` |
| Pagado | `sí` | `boolean` | `tinyint(1)` | `tinyint(1)` | `BOOLEAN` | `bit` | `NUMBER(1)` |

## Load the script into your database

The download is a plain .sql file. Each database runs it with its own tools.

### PostgreSQL

```shell
psql -v ON_ERROR_STOP=1 -d mydb -f ventas_2024.postgresql.sql
```

ON_ERROR_STOP makes psql stop at the first error. The script runs in one transaction, so a failed load leaves the database as it was. In pgAdmin or DBeaver, open the script in a query window and run it.

Without a script:

```shell
intosql load ventas_2024.csv --into postgres://user@localhost/mydb
```

### MySQL

```shell
mysql --default-character-set=utf8mb4 mydb < ventas_2024.mysql.sql
```

The script sets utf8mb4 itself; the flag makes the client send it the same way, so accents arrive intact. In MySQL Workbench, choose File, Run SQL Script, and pick the file.

Without a script:

```shell
intosql load ventas_2024.csv --into mysql://user@localhost/mydb
```

### MariaDB

```shell
mariadb --default-character-set=utf8mb4 mydb < ventas_2024.mariadb.sql
```

The script sets utf8mb4 itself; the flag makes the client send it the same way, so accents arrive intact. In HeidiSQL or DBeaver, open the script and run it.

Without a script:

```shell
intosql load ventas_2024.csv --into mariadb://user@localhost/mydb
```

### SQLite

```shell
sqlite3 ventas_2024.db < ventas_2024.sqlite.sql
```

The database file is created if it doesn't exist. The converter also downloads a ready .sqlite database, with no command at all. In DB Browser for SQLite, choose Execute SQL, open the script and run it.

Without a script:

```shell
intosql load ventas_2024.csv --into ventas_2024.db
```

### SQL Server

```shell
sqlcmd -S localhost -d mydb -f 65001 -i ventas_2024.sql_server.sql
```

-f 65001 reads the file as UTF-8, so accents and ñ arrive as written. In SQL Server Management Studio or Azure Data Studio, open the file and choose Execute.

### Oracle

```shell
sqlplus user@//localhost/mydb @ventas_2024.oracle.sql
```

The script turns off substitution variables (SET DEFINE OFF), so an ampersand in your data stays an ampersand. In SQL Developer, open the script and choose Run Script (F5).

## What IntoSQL reads in CSV files

- The encoding is detected, Windows-1252 and UTF-16 included, so accents and ñ arrive intact.
- The separator is detected: comma, semicolon, tab or vertical bar. With a semicolon, decimal commas like 1.234,50 are read as numbers.
- Quoted values can hold separators and line breaks.

## What to know about each database

- Pick the database once the file is open: each one gets the types it supports.

### How each kind of value is stored in each database

| Value | PostgreSQL | MySQL | MariaDB | SQLite | SQL Server | Oracle |
| --- | --- | --- | --- | --- | --- | --- |
| Yes and no | `boolean` | `tinyint(1)` | `tinyint(1)` | `BOOLEAN` | `bit` | `NUMBER(1)` |
| Whole numbers | `integer` | `int` | `int` | `INTEGER` | `int` | `NUMBER(10)` |
| Large whole numbers | `bigint` | `bigint` | `bigint` | `INTEGER` | `bigint` | `NUMBER(19)` |
| Decimals | `numeric(p,s)` | `decimal(p,s) · double` | `decimal(p,s) · double` | `NUMERIC(p,s) · TEXT` | `decimal(p,s)` | `NUMBER(p,s)` |
| Floating-point numbers | `double precision` | `double` | `double` | `REAL` | `float` | `BINARY_DOUBLE` |
| Dates | `date` | `date` | `date` | `DATE` | `date` | `DATE` |
| Times of day | `time` | `time(6) · time` | `time(6) · time` | `TIME` | `time` | `INTERVAL DAY(0) TO SECOND` |
| Dates with a time | `timestamp` | `datetime(6) · datetime` | `datetime(6) · datetime` | `DATETIME` | `datetime2` | `TIMESTAMP` |
| Dates with a time and offset | `timestamptz` | `datetime(6) · datetime` | `datetime(6) · datetime` | `DATETIME` | `datetimeoffset` | `TIMESTAMP WITH TIME ZONE` |
| Text | `text` | `varchar(n) · text · mediumtext · longtext` | `varchar(n) · text · mediumtext · longtext` | `TEXT` | `nvarchar(n) · nvarchar(max)` | `VARCHAR2(n CHAR) · CLOB` |

## Questions about CSV to SQL

### How do I convert CSV to SQL?

Drop your file on the converter at the top of this page and choose your database: PostgreSQL, MySQL, MariaDB, SQLite, SQL Server or Oracle. Each one gets the types it supports. Download the script and run it in your database.

### What if my CSV uses semicolons or tabs?

The separator is detected: comma, semicolon, tab or vertical bar. You can also set it under More options. With a semicolon, decimal commas such as 1.234,50 are read as numbers.

### Which types does it use in each database?

Each database gets its own: yes and no values are boolean in PostgreSQL, tinyint(1) in MySQL and MariaDB, bit in SQL Server and NUMBER(1) in Oracle. The table on this page lists every kind of value.

### Does it keep leading zeros?

Yes. A code such as 00412 stays text in every database, written as '00412', so no zero is lost.

### Can it load the data without a script?

Yes. The command line loads into SQLite for free, and with IntoSQL Pro the desktop app and the command line load into PostgreSQL, MySQL and MariaDB. For SQL Server and Oracle, run the script.

### How big can the CSV file be?

The browser reads a CSV as it streams in, so files of several gigabytes work. On an Apple M4 laptop the command line converts a 174 MB CSV of a million rows in under a second.

## CSV into other databases

- [Convert CSV to PostgreSQL](https://intosql.com/csv-to-postgresql)
- [Convert CSV to MySQL](https://intosql.com/csv-to-mysql)
- [Convert CSV to MariaDB](https://intosql.com/csv-to-mariadb)
- [Convert CSV to SQLite](https://intosql.com/csv-to-sqlite)
- [Convert CSV to SQL Server](https://intosql.com/csv-to-sql-server)
- [Convert CSV to Oracle](https://intosql.com/csv-to-oracle)

## Other files into SQL

- [Convert Excel to SQL](https://intosql.com/excel-to-sql)
- [Convert JSON to SQL](https://intosql.com/json-to-sql)
