RevealTheme logo

CSV ke SQL INSERT

Hasilkan pernyataan SQL INSERT dari data CSV. Berguna untuk mengimpor ekspor CSV ke dalam basis data.

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

Cara menggunakan alat ini

  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.

Apa itu CSV ke SQL INSERT?

Mengimpor CSV secara massal ke dalam basis data biasanya memerlukan pernyataan INSERT. Generator ini menghasilkan INSERT SQL standar yang berfungsi di MySQL, PostgreSQL, SQLite, dan sebagian besar DBMS lainnya. Untuk CSV yang sangat besar (lebih dari 10.000 baris), sebaiknya gunakan utilitas bawaan basis data Anda (LOAD DATA / COPY FROM): utilitas tersebut jauh lebih cepat hingga beberapa kali lipat.

Kasus penggunaan umum

  • 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.

Pertanyaan yang sering diajukan

Apakah alat ini menangani karakter khusus dalam nilai?
Ya: tanda kutip tunggal di-escape dengan benar.
Bagaimana dengan nilai NULL?
Sel kosong dikonversi menjadi string kosong. Ganti dengan NULL secara manual jika diperlukan.

Alat terkait