MySQL LOAD DATA INFILE store line number

≯℡__Kan透↙ 提交于 2019-11-29 17:21:39

You can do that by setting a user variable first, and increment this variable in your SET clause, i.e.

SET @a:=0;                                       -- initialize the line count
LOAD DATA INFILE 'c:/tools/import.csv'           -- my test import 
REPLACE
INTO TABLE tableName 
FIELDS TERMINATED BY ',' ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES # first row is column headers
(fieldA,fieldB,fieldC)
SET import_date = now(), 
import_file = 'import.csv',               
import_line = @a:=@a+1;                          -- save the incremented line count
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!