csv表中含有中文字符,具體實作程式碼範例:
load data infile 'C:\\Users\\Administrator\\Desktop\\import\\CELLutf.csv' into table cell character set gbk(設定gbk字元編碼,防止中文亂碼)
fields terminated by ','
enclosed by '"'
lines terminated by '\r\n'
IGNORE 1 LINES;
程式碼解釋:
fields terminated by ',':csv檔案中資料之間的分隔符,csv檔案預設以逗號分隔;
enclosed by '':指出封套符;
lines terminated by '':指行終止符;
IGNORE 1 LINES:忽略csv表頭。
以上是分享csv匯入資料到mysql實例的詳細內容。更多資訊請關注PHP中文網其他相關文章!