您好,欢迎访问一九零五行业门户网

mysql outfile infile导入导出数据_MySQL

bitscn.com
mysql outfile infile导入导出数据
导出
[plain] 
select * into outfile '/tmp/jason.txt' fields terminated by ',' from test.jason;
或者
[plain] 
select * into outfile '/tmp/jason1.txt' fields terminated by ',' optionally enclosed by '' lines terminated by '/n' from test.jason1;  
输出:
        2013-04-09 00:06:56,100000198108800,export_info,buy_item_inner,65,10,1004,10,11,2,100
        2013-04-09 00:06:59,1068029027,export_info,buy_item_inner,16,7,304,7,11,2,70
        2013-04-09 00:08:27,100000198108800,export_info,buy_item_inner,65,2,1004,2,11,2,20
导入
[plain] 
load data infile '/tmp/jason.txt' into table aa.jason fields terminated by ',';
或者
[plain] 
load data infile '/tmp/jason1.txt' into table aa.jason1 fields terminated by ',' optionally enclosed by '' lines terminated by '/n';
总结:
fields terminated by ',' 字段间分割符
optionally enclosed by '' 将字段包围 对数值型无效
lines terminated by '/n' 换行符
mysqldump也有同样功能
[plain] 
mysqldump -uroot -p -t /tmp test fi --fields-enclosed-by=/ --fields-terminated-by=/t
fi 是导出的文件名,默认添加.txt
test 是要导出的库名
-t /tmp 是导出的目录位置
--fields-enclosed-by=/ 是每个数据都在双引号里面
--fields-terminated-by=/t 表示每个数据是以制表符分割的
bitscn.com
其它类似信息

推荐信息