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 نیاز دارد. این مولد دستورهای INSERT استاندارد SQL تولید می‌کند که در MySQL، PostgreSQL، SQLite و بیشتر سامانه‌های مدیریت پایگاه داده دیگر کار می‌کنند. برای فایل‌های CSV بسیار بزرگ (بیش از ۱۰٬۰۰۰ سطر)، استفاده از ابزار بومی پایگاه داده شما (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 جایگزین کنید.

ابزارهای مرتبط