导出mysql数据到文件

来源:互联网 发布:淘宝微商城怎么开通 编辑:程序博客网 时间:2024/05/21 11:34
MySQL Select into outfile用于导出指定的查询数据到文件

1.导出表中所有ip数据到D盘根目录outfile.txt中
select ip into outfile 'd:/outfile.txt' from log;

2.导出表中所有数据到D盘根目录outfile.txt中
select into outfile 'd:/outfile.txt' fieldsterminated by ',' from log;
再导回到数据库中
load data infile 'd:/outfile.txt'into table log fields terminated by ',' lines terminated by'\n'
2.MYSQL不支持
Select Into new_table_name from old_table_name
替代方法:
Create table new_table_name (Select from old_table_name);