1. 程式人生 > >MySQL 匯出CSV檔案,長資料低位變為00000的問題

MySQL 匯出CSV檔案,長資料低位變為00000的問題

匯出CSV表,使用excel或WPS開啟後發現數據超過15位的後面全變成了00000;

原來使用的匯出語句:

SELECT * INTO OUTFILE '/tmp/test.csv'   FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM test.test;

修改後的匯出語句:關鍵點在於將enclosed by 後的分隔符從雙引號變成\t;

SELECT * INTO OUTFILE '/tmp/test.csv'   FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\t' LINES TERMINATED BY '\n' FROM test.test;

再開啟後不再有低位變成00000的現象。