csv文件導(dǎo)入數(shù)據(jù)庫的格式和平時(shí)導(dǎo)入其他文件是一樣的,都需要使用load data infile 語句,但是最關(guān)鍵的是格式參數(shù): 下面是舉例: use ip; load data infile E:/ip-to-country.csv into table `ip-to-country-isp` fields terminated by , optionally enclos
csv文件導(dǎo)入數(shù)據(jù)庫的格式和平時(shí)導(dǎo)入其他文件是一樣的,都需要使用load data infile 語句,但是最關(guān)鍵的是格式參數(shù):
下面是舉例:
use ip;
load data infile 'E:/ip-to-country.csv' into table `ip-to-country-isp` fields terminated by ',' optionally enclosed by '"' escaped by '"' lines terminated by '\r\n';
附ip-to-country的表結(jié)構(gòu):
CREATE TABLE `ip-to-country-isp` ( `start` bigint(20) default NULL, `end` bigint(20) default NULL, `country` varchar(11) default NULL, `country2` varchar(11) default NULL, `des` varchar(50) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
select * from ip-to-country-isp into outfile 'E:/ip-to-country-isp.csv' fields terminated by ',' optionally enclosed by '"' escaped by '"' lines terminated by '\r\n';
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com