import csv to mysql

import csv to mysql

 

//open temp.csv
vim temp.csv
:%s/"//

// create

create table temp( id int primary key auto_increment, char_min varchar(32),char_max varchar(32),in_min varchar(32),in_max varchar(32),country_code varchar(32),country_name varchar(32));
create table IPCountryWhois( id int primary key auto_increment, char_min varchar(32),char_max varchar(32),in_min int,in_max int,country_code varchar(32),country_name varchar(32));

// import into temp table

// create temp table then convert varchar to ingeger and insert into IPCountryWhois

 

// convert and insert
insert into IPCountryWhois(char_min, char_max,in_min,in_max,country_code,country_name) select char_min,char_max,convert(in_min,unsigned),convert(in_max,unsigned),country_code,country_name from temp;

版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章出处,否则按侵权处理.

    分享到:

Leave a Reply

Your email address will not be published. Required fields are marked *