mysql1条语句导出数据
很多人经常要处理一些数据,用一些数据库方法比如navicat for mysql 、 sqlyog、以及phpmyadmin之类的东西,可是试了很多,创建都导入不全,
尴尬了,开首照样决定写SQL语句来搞吧,mysql外观有个load data infile 很强大,或许高速从文件导入数据,并且设置好了不会丢失数据。
导入示例:
Default load data infile ‘C:seay.csv’ into table 表名
CHARACTER SET utf8
fields terminated by ‘;'
optionally enclosed by ‘”‘
lines terminated by ‘rn’ (列1,列2)
123四5
load data infile ‘C:seay.csv’ into table 表名CHARACTER SET utf8fields terminated by ‘;’optionally enclosed by ‘”‘lines terminated by ‘rn’ (列1,列2)
导出示例:
Default select * from test_info
into outfile ‘C:/seay.csv'
fields terminated by ‘,’ optionally enclosed by ‘”‘ escaped by ‘”‘
lines terminated by ‘rn’;
123四
select * from test_info into outfile ‘C:/seay.csv’ fields terminated by ‘,’ optionally enclosed by ‘”‘ escaped by ‘”‘ lines terminated by ‘rn’;
阐明:
Default CHARACTER SET utf8 设置编码
fields terminated by ‘;’ 合并标识符
optionally enclosed by ‘”‘ 内容以双引号包住
lines terminated by ‘rn’ (列1,列2) 换行rn
123四5六
CHARACTER SET utf8 设置编码 fields terminated by ‘;’ 合并标识符optionally enclosed by ‘”‘ 内容以双引号包住 lines terminated by ‘rn’ (列1,列2) 换行rn