P粉2324090692023-08-30 11:31:45
Load data into a table in MySQL and specify columns:
LOAD DATA LOCAL INFILE 'file.csv' INTO TABLE t1 FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (@col1,@col2,@col3,@col4) set name=@col4,id=@col2 ;
@col1,2,3,4 are variables that save csv file columns (assuming 4) name,id are table columns.