CSV to SQL Converter
Instantly convert CSV data to SQL INSERT/UPDATE statements
in your browser securely and for free.
資料表設定
選項
輸入 CSV
輸出 SQL
關於 CSV 轉 SQL 產生器
這是一款為開發者設計的免費工具,能夠將 CSV 文件即時轉換為 SQL 的 INSERT 或 UPDATE 語句。在將 Excel 或試算表數據轉移到資料庫時,能節省大量時間並減少人為錯誤。
所有的轉換過程完全在您的瀏覽器內進行。即使 CSV 文件包含客戶名單或機密信息,也不會上傳到任何伺服器,保證數據安全。
如何將 CSV 轉換為 SQL
設定參數
填寫資料表名稱,選擇 SQL 類型 (INSERT 或 UPDATE),並根據需求勾選選項。
準備 CSV 數據
將 CSV 數據貼上或上傳文件。如果您想使用第一行作為欄位名稱,請勾選該選項。
生成並複製 SQL
點擊「產生 SQL」按鈕,即可瞬間獲得 SQL 語句。複製後在您的資料庫中執行即可。
SQL 與資料庫詞彙表
- CSV (逗號分隔值)
- 一種使用逗號分隔數據的純文字格式,廣泛用於與 Excel 等軟體進行數據交換。
- SQL (結構化查詢語言)
- 用於管理和操作關聯式資料庫系統 (RDBMS) 的標準程式語言。
- INSERT 語句
- 用於將新數據行(記錄)插入資料庫表中的 SQL 指令。
- UPDATE 語句
- 用於修改現有資料庫記錄的 SQL 指令,通常結合 WHERE 子句使用。
- 轉義 (Escaping)
- 確保將 SQL 中具有特殊含義的字元(如單引號)視為純文字的安全處理過程。
常見問題
- Q.Is the CSV data I enter saved on external servers?
- No, all input data is processed strictly within your PC or smartphone's browser. There is no transmission or storage of data to external servers, making it completely safe to use even with CSV files containing customer lists or sensitive information.
- Q.Can it convert huge CSV files with tens of thousands of rows?
- Yes, it can, but it depends on your browser's memory and processing power. Processing a few thousand to tens of thousands of rows usually completes in seconds. However, for extremely large files exceeding 100,000 rows, we recommend splitting the file before conversion to prevent browser freezing.
- Q.How are numeric and string data distinguished?
- The tool automatically analyzes the value of each cell internally. If it consists only of numbers (or numbers with a decimal point), it is treated as a number and quotes are removed. This automatic inference can also be disabled in the options, allowing you to force all values to be quoted as strings if required.
- Q.How are NULL values or empty cells handled?
- Empty cells or the string 'NULL' are output to SQL as `NULL` without quotes so that they are treated as official NULLs in the database. If you intentionally want them registered as empty strings (`''`), please adjust the CSV data beforehand or manually tweak the generated SQL.
- Q.Can I use the output with both MySQL and PostgreSQL?
- Yes, the basic INSERT and UPDATE statements are generated using standard SQL syntax, so you can use them directly in major relational databases like MySQL, PostgreSQL, SQLite, and SQL Server. If specific functions or dialects are required, please replace them in the output SQL using a text editor.
應用場景
初始數據匯入
在系統開發時,非常適合將 Excel 中的初始或測試數據批量匯入資料庫。
批量更新主數據
能夠快速生成 UPDATE 語句,以便使用經常更新的商品或分類數據來覆蓋現有表。
異構系統數據遷移
協助將舊系統導出的 CSV 文件轉換為符合新系統表結構的 SQL 語句。
製作修復補丁
當數據損壞時,可通過正確的 CSV 名單,精確且快速地生成數據修復的 SQL。
發送反饋
請告訴我們您的想法,以幫助我們改進工具。
Feedback is temporarily suspended
The server is busy or spam protection is active. Please try again later.