Convert CSV to MariaDB
Drop your CSV file to get a MariaDB script with CREATE TABLE and INSERT statements. Each column gets a type, and every fix is listed with its row and column.
5 rows converted, 8 fixes, none rejected
| Row | ||||||
|---|---|---|---|---|---|---|
| 5 | 00412 | Peña Muñoz | Mérida | 15/02/2024 | 1.234,50 | sí |
| 6 | 00413 | José Ángel Ruiz | León | 03/02/2024 | 99,90 | no |
| 7 | 00414 | Zoë Ortíz | Querétaro | 29/02/2024 | N/A | sí |
| 8 | 00415 | Ñuño Castañeda | Oaxaca | 28/02/2024 | 7,25 | no |
| 9 | 00416 | Iñaki Olaizola | Mazatlán | 11/03/2024 | 980,75 | sí |
-- Written by IntoSQL for MariaDB.
SET NAMES utf8mb4;
SET SESSION sql_mode = REPLACE(@@sql_mode, 'NO_BACKSLASH_ESCAPES', '');
START TRANSACTION;
CREATE TABLE ventas_2024 (
folio varchar(8) NOT NULL,
cliente varchar(16) NOT NULL,
ciudad varchar(16) NOT NULL,
fecha date NOT NULL,
importe decimal(6,2),
pagado tinyint(1) NOT NULL
) DEFAULT CHARSET=utf8mb4;
INSERT INTO ventas_2024 (folio, cliente, ciudad, fecha, importe, pagado) VALUES
('00412', 'Peña Muñoz', 'Mérida', '2024-02-15', 1234.50, TRUE),
('00413', 'José Ángel Ruiz', 'León', '2024-02-03', 99.90, FALSE),
('00414', 'Zoë Ortíz', 'Querétaro', '2024-02-29', NULL, TRUE),
('00415', 'Ñuño Castañeda', 'Oaxaca', '2024-02-28', 7.25, FALSE),
('00416', 'Iñaki Olaizola', 'Mazatlán', '2024-03-11', 980.75, TRUE);
COMMIT;
Fixes
- The file was written in windows‑1252; it was converted to UTF-8.
- The header is on row 4; the rows above it were left out.
- Row 10 ("TOTAL") is a total, so it was left out.
- Leading zeros kept in "Folio": 00412 stays 00412, stored as text.
- 15/02/2024 proves the dates in "Fecha" are day-first, so 03/02/2024 is read as 2024‑02‑03.
- Numbers in "Importe" use a decimal comma: 1.234,50 is read as 1234.50.
- N/A in "Importe" read as empty (1 of 5 values).
- "Pagado" holds yes and no words (sí, no), stored as boolean.
Your file is converted on this computer and never uploaded.
Other samples:
From CSV to MariaDB, column by column
The sample above, ventas_2024.csv, as IntoSQL writes it for MariaDB: what each column holds in the file, the type it gets and how its first value lands in the script.
| In the file | First value | Column | MariaDB type | In the script |
|---|---|---|---|---|
| Folio | 00412 | folio | varchar(8) | '00412' |
| Cliente | Peña Muñoz | cliente | varchar(16) | 'Peña Muñoz' |
| Ciudad | Mérida | ciudad | varchar(16) | 'Mérida' |
| Fecha | 15/02/2024 | fecha | date | '2024-02-15' |
| Importe | 1.234,50 | importe | decimal(6,2) | 1234.50 |
| Pagado | sí | pagado | tinyint(1) | TRUE |
Load the script into MariaDB
The download is a plain .sql file. Run it with MariaDB's own tools.
From a terminal
mariadb --default-character-set=utf8mb4 mydb < ventas_2024.mariadb.sqlThe script sets utf8mb4 itself; the flag makes the client send it the same way, so accents arrive intact.
From a database tool
In HeidiSQL or DBeaver, open the script and run it.
Without a scriptPro
IntoSQL Pro loads the file straight into MariaDB from the desktop app or the command line, without writing a script.
intosql load ventas_2024.csv --into mariadb://user@localhost/mydbWhat to know about CSV files and MariaDB
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 MariaDB
- Yes and no values become tinyint(1). Text up to 255 characters is varchar; longer text is text, mediumtext or longtext by size.
- The script uses utf8mb4 and sets the SQL mode, so accents, emoji, backslashes and line breaks load as written.
- MariaDB's datetime stores no time zone.
How each kind of value is stored in MariaDB
| Value | MariaDB |
|---|---|
| Yes and no | tinyint(1) |
| Whole numbers | int |
| Large whole numbers | bigint |
| Decimals | decimal(p,s)double |
| Floating-point numbers | double |
| Dates | date |
| Times of day | time(6)time |
| Dates with a time | datetime(6)datetime |
| Dates with a time and offset | datetime(6)datetime |
| Text | varchar(n)textmediumtextlongtext |
Questions about CSV to MariaDB
Not answered here? Write to us from the contact page and a person replies. Contact page
How do I convert CSV to MariaDB?
Drop your file on the converter at the top of this page. It finds the header, reads every value and writes the MariaDB script, listing each fix it made. Download the script and run it with the mariadb client.
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 MariaDB types does it use?
Yes and no values become tinyint(1), whole numbers int, decimals decimal(p,s), dates date, dates with a time datetime(6) and text varchar(n). Sizes come from the longest value in each column.
Does it keep leading zeros in MariaDB?
Yes. A code such as 00412 stays text, so MariaDB stores it as varchar(8) and the script writes it as '00412'.
Can it load the data into MariaDB without a script?
Yes, with IntoSQL Pro. The desktop app and the command line connect to MariaDB and load the rows straight in, creating the table first.
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.