# CSV Flavor to SQL INSERT Emitter

Parse CSV/Excel-CSV/TSV (auto dialect, RFC 4180) into MySQL/PostgreSQL/SQLite/SQL Server INSERT batches with type inference and ON CONFLICT/IGNORE

> Canonical page: https://elysiatools.com/en/tools/csv-flavor-to-sql-insert-emitter

- **Category:** Format Conversion

- **Keywords:** csv, sql, insert, etl, 数据库, mysql, postgresql, sqlite, sqlserver, tsv, rfc4180, 冲突, upsert

## Overview

把表格文本转成可直接运行的 SQL INSERT 批。自动检测分隔符(逗号/分号/制表符/竖线)、处理 UTF-8 BOM、按 RFC 4180 解析带引号字段。逐列推断类型(BIGINT/DOUBLE/BOOLEAN/DATE/TIMESTAMP/TEXT)。四种方言:MySQL/PostgreSQL/SQLite/SQL Server。支持 ON CONFLICT/IGNORE/upsert 幂等变体。区别于只读 Excel 的 xlsx-sql-insert-generator。

## Inputs

- **CSV / Excel-CSV / TSV Data** (textarea): Paste CSV here, e.g. id,name,amount 1,Alice,99.50 2,Bob,
- **SQL Dialect** (select)
- **Delimiter** (select)
- **Table Name** (text): e.g. customers
- **Null Token** (select)
- **On Conflict** (select)
- **Conflict Target Column** (text): e.g. id (for postgres upsert)
- **Batch Size (multi-row)** (number)
- **Multi-row VALUES** (checkbox)
- **First row is header** (checkbox)
- **Emit CREATE TABLE** (checkbox)

## When to use

- Convert pasted CSV or TSV data into SQL INSERT statements for a selected database dialect.
- Import table data with automatically inferred BIGINT, DOUBLE, BOOLEAN, DATE, TIMESTAMP, or TEXT column types.
- Create repeatable imports using ignore or upsert conflict modes.

## How it works

- Paste the table text and choose whether the first row contains column headers.
- Select a SQL dialect and let the tool detect the delimiter or choose comma, semicolon, tab, or pipe.
- Set the table name, null token, batch size, and multi-row VALUES option.
- Choose normal INSERT, ignore, or upsert output, then generate the SQL batch.

## Use cases

- Load small exports into PostgreSQL, MySQL, SQLite, or SQL Server without writing each INSERT manually.
- Convert semicolon-delimited Excel-CSV data into database-specific INSERT statements.
- Build repeatable data imports with batched VALUES and ignore or upsert conflict behavior.

## Frequently asked questions

### Which input formats are supported?

The tool accepts CSV, Excel-style CSV, and TSV text.

### Which SQL dialects can it generate?

It generates SQL for PostgreSQL, MySQL, SQLite, and SQL Server.

### Can it detect the delimiter automatically?

Yes. It can detect commas, semicolons, tabs, and pipes, or you can select a delimiter.

### How are column types determined?

The tool infers types by column, including BIGINT, DOUBLE, BOOLEAN, DATE, TIMESTAMP, and TEXT.

### How are empty or special null values handled?

You can treat empty strings, NULL, N/A, or dashes as null tokens.

## Related tools

- [CSV to Excel Converter](https://elysiatools.com/en/tools/csv-to-excel): Convert CSV data to Excel format with customizable parsing and formatting options
- [Text to Excel Converter](https://elysiatools.com/en/tools/text-to-excel): Convert various text formats to Excel with customizable parsing and formatting options
- [Excel to CSV Converter](https://elysiatools.com/en/tools/excel-to-csv): Convert Excel file to CSV format, extracting data from the first worksheet
- [Barcode Batch Generator](https://elysiatools.com/en/tools/barcode-batch-generator): Batch generate Code 128, EAN-13, UPC-A, ITF-14, QR Code, and Data Matrix outputs from CSV or multiline text
- [XLSX CSV Batch Converter](https://elysiatools.com/en/tools/xlsx-csv-batch-converter): Batch convert CSV/TSV to XLSX or convert XLSX back to CSV/TSV with delimiter and encoding handling
- [XLSX Sheet to CSV Pack](https://elysiatools.com/en/tools/xlsx-sheet-to-csv-pack): Export each Excel worksheet as an individual CSV file and include a manifest with schema/statistics
- [XLSX SQL Insert Generator](https://elysiatools.com/en/tools/xlsx-sql-insert-generator): Read Excel headers and rows to generate SQL INSERT statements for bulk loading
- [XLSX CSV Detect Normalize](https://elysiatools.com/en/tools/xlsx-csv-detect-normalize): Auto-detect CSV delimiter/encoding (UTF-8/GBK), normalize the table, and import to XLSX/CSV

## Samples

- [SQL Scripts Samples](https://elysiatools.com/en/samples/sql-samples): SQL query examples and database scripts for various scenarios and use cases (primarily MySQL syntax)
- [CSV Samples](https://elysiatools.com/en/samples/csv-samples): Sample CSV files with various data types, sizes, and complexity levels
- [SQL Injection Samples](https://elysiatools.com/en/samples/sql-injections): Educational collection of SQL injection payloads for security testing, vulnerability assessment, and defensive coding practices
- [SQL Viewer Samples](https://elysiatools.com/en/samples/sql-viewer-samples): Sample SQL scripts (DDL/DML, joins, CTEs) for the in-browser SQL Viewer
