回覆列表
  • 1 # tliglle

      mysql匯出資料庫到csv檔案的方法:  

    1、透過mysql客戶端shell連線到伺服器,選擇使用的資料庫,輸入sql程式碼:  select * from test_infointo outfile "/tmp/test.csv" fields terminated by "," optionally enclosed by """ escaped by """ lines terminated by "\r\n";   裡面最關鍵的部分就是格式引數  這個引數是根據RFC4180文件設定的,該文件全稱Common Format and MIME Type for Comma-Separated Values (CSV) Files,其中詳細描述了CSV格式,其要點包括:  (1)欄位之間以逗號分隔,資料行之間以\r\n分隔;  (2)字串以半形雙引號包圍,字串本身的雙引號用兩個雙引號表示。  透過執行上述程式碼,便可以將需要的資料以csv格式匯出到執行的檔案中。    

    2、另外,MySQL中匯入CSV格式資料的sql程式碼如下:  load data infile "/tmp/test.csv"into table test_info fields terminated by "," optionally enclosed by """ escaped by """ lines terminated by "\r\n";

  • 中秋節和大豐收的關聯?
  • 如何清洗髮黃象牙經常佩帶的象牙項鍊時間長了發黃?