MySQL匯入匯出平面檔案

壹頁書發表於2014-06-16
MySQL可以非常方便的匯入匯出平面檔案。

測試如下.


匯出為平面檔案
  1. select * from t1 into outfile 'F:/backup.sql' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';

    平面檔案如下:
    1,"u1"
    2,"u2"
    3,"u3"

匯入平面檔案

  1. LOAD DATA INFILE 'F:/backup.sql' INTO TABLE mvbox.t1 FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';



    FIELDS TERMINATED BY  ','  欄位間分割符
    OPTIONALLY ENCLOSED BY  '"'  將欄位包圍 對數值型無效
    LINES TERMINATED BY  '\n' 換行符 


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29254281/viewspace-1183701/,如需轉載,請註明出處,否則將追究法律責任。

相關文章