RevealTheme logo

تحويل CSV إلى SQL INSERT

أنشئ عبارات SQL INSERT من بيانات CSV. مفيدة لاستيراد ملفات 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 الضخمة جدًا (أكثر من 10000 صف)، فالأفضل استخدام الأداة الأصلية في قاعدة بياناتك (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 يدويًا إذا لزم الأمر.

أدوات ذات صلة