Mysql
HeidiSQL:導入 CSV
我的 CSV 的幾行:
"id","date","date_","pow","ene","reac" "ES0134000563024539AM0F","2013-05-02","2013-06-05","62","43","43" "ES0134000573024539AM0F","2013-05-02","2013-06-05","62","43","43" "ES0134000563224539AM0F","2013-05-02","2013-06-05","62","43","43"
我嘗試導入文本文件,但收到程式碼為 1261 的錯誤消息。我使用了以下控製字元:
- 欄位終止於:
"
- 由以下內容包圍的欄位:
,
- 欄位轉義:
"
- 行終止於:
\r\n
根據文件,您的錯誤是:
錯誤:1261 SQLSTATE: 01000 (ER_WARN_TOO_FEW_RECORDS) 消息:行%ld不包含所有列的數據。
因此,您的表格似乎比文件具有更多的列。您必須明確指定列名。其餘列也應該可以為空。(如果以下命令不起作用,您可能希望共享表定義)
嘗試這個:
LOAD DATA INFILE 'path/to/file' INTO TABLE your_table FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES (id,date,date_,pow,ene,reac);
如果您有興趣,您可能想參考這篇部落格文章,它解釋了將分隔數據載入到 mysql的各種案例。