RevealTheme logo

CSV에서 SQL INSERT로

CSV 데이터로부터 SQL INSERT 문을 생성합니다. CSV 내보내기 파일을 데이터베이스로 가져올 때 유용합니다.

INSERT INTO my_table (name, value) VALUES ('A', '1');
INSERT INTO my_table (name, value) VALUES ('B', '2');

이 도구 사용 방법

  1. 1

    Type the destination table name into the top field (it is dropped into the generated INSERT exactly as typed).

  2. 2

    Paste your CSV into the text box, keeping the header row first so its names become the column list.

  3. 3

    Read the INSERT statements that appear below as you type, with one statement per data row.

  4. 4

    Select the generated SQL and copy it into your database client or migration script to run it.

CSV에서 SQL INSERT란 무엇인가요?

CSV를 데이터베이스로 대량 가져오기 하려면 보통 INSERT 문이 필요합니다. 이 생성기는 MySQL, PostgreSQL, SQLite 및 대부분의 다른 DBMS에서 작동하는 표준 SQL INSERT 문을 생성합니다. 매우 큰 CSV(10,000행 이상)의 경우에는 데이터베이스의 기본 유틸리티(LOAD DATA / COPY FROM)를 사용하는 것이 좋습니다. 이는 자릿수가 다를 정도로 훨씬 빠릅니다.

일반적인 사용 사례

  • Seeding a few rows of test or fixture data into a local development database without writing the INSERTs by hand.

  • Converting a small spreadsheet export of lookup values (statuses, categories, country codes) into a migration script.

  • Drafting INSERT statements for a quick demo or tutorial where the data is short and contains no commas inside fields.

  • Reshaping a handful of rows copied from a CSV file into SQL you can paste into a query console.

  • Generating a starting point for a data-load script that you will then hand-edit to add NULLs or fix column types.

  • Teaching or learning SQL INSERT syntax by watching how column lists and quoted values are assembled from rows.

자주 묻는 질문

값에 포함된 특수 문자를 처리하나요?▼
예. 작은따옴표는 올바르게 이스케이프됩니다.
NULL 값은 어떻게 처리하나요?▼
빈 셀은 빈 문자열로 변환됩니다. 필요한 경우 수동으로 NULL로 바꾸세요.

관련 도구