insert csv file data into mysql -
i want insert data mysql table csv file. import data region_codes.csv file. in region_codes.csv file having 3 columns in 3rd columns had , separated data, include commas how insert in mysql.
drop table if exists `region_codes`; create table `region_codes` ( `country_code` char(2) null, `region_no` varchar(5) not null, `region` varchar(45) null, index `idx_country_code` (`country_code`) ) collate='utf8_bin' engine = myisam; using load data local infile import data 1000 rows imported outof 4066 rows.
load data local infile 'c:/region_codes.csv' table `region_codes` fields terminated ',' enclosed '"' lines terminated '\n'; how insert huge amount of data mysql region_codes table csv file.
screenshot: 
you can try below syntax if works otherwise provide csv data:
load data local infile 'c:/region_codes.csv' table `region_codes` fields escaped '\\' fields terminated ',' enclosed '"' lines terminated '\r\n'; if above syntax not work export data below command again , import below given command.
select * outfile 'c:/region_codes.csv' fields terminated ',' optionally enclosed '"' lines terminated '\n' `region_codes`; now use below command (to ignore column heading line)
load data local infile 'c:/region_codes.csv' table `region_codes` fields escaped '\\' fields terminated ',' enclosed '"' lines terminated '\r\n' ignore 1 lines; note: if data prepared manually need correct manually.
if still not work attach csv data check exact problem.
Comments
Post a Comment