- mysql -u <user> -p --local-infile
(the --local-infile is necessary, otherwise you will get error during dataloading: ERROR 1148 (42000): The used command is not allowed with this MySQL version) - use <database>
- create table script (create_tables.sql) in text editor
drop table kontakt;
create table kontakt
(klkood bigint(20)
,kontakti_liik varchar(32)
,vaartus varchar(100)
,kasutusluba varchar(100)
,keeluaeg varchar(100)
);
create index kontakt_klkood on kontakt(klkood); - run the script from mysql prompt
.\ create_tables.sql - create load data script (load_data.sql) in text editor
LOAD DATA LOCAL INFILE '/vagrant/uptime/EA_kliendi_kontaktinfo_3012.csv' INTO TABLE kontakt
FIELDS TERMINATED BY ';'
LINES STARTING BY '"' TERMINATED BY '"\r\n'
IGNORE 1 LINES; - run the script from mysql prompt
.\ load_data.sql - If there are warnings then execute
show warnings
Tuesday, December 31, 2013
How to load CSV file to Mysql database
There some tricks to know how to load csv file to mysql:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment