示例:


 SELECT email FROM xxxxxx where email is not null and email <> ''  into  outfile '/mail.txt' lines terminated by '\r\n' ;


SELECT email FROM u_emails where email is not null and email <>'' and email like '%@163.com%' LIMIT 0 ,10 into outfile '/163.txt' lines terminated by ';\r\n';


SELECT email FROM u_emails where email is not null and email <>'' and email not like '%@163.com%' and email not like '%@sina.com%' and email not like '%@qq.com%' LIMIT 0 ,10 into outfile '/other.txt' lines terminated by ';\r\n';

 

说明:


1.导出文件目录:


修改输出文件名的目录,以便放在指定的位置。如'a.txt'可以改成'./a.txt'或'/a.txt'。

其中'./a.txt'放在c:\mysql\data目录下了,

而'/a.txt'文件则放在c:\目录下了。


select命令认为的当前目录是数据库的存放目录


 


2.导出数据格式 


字段之间的分隔字符,转义字符,包括字符,及记录行分隔字符。列在下面: 

FIELDS

TERMINATED BY '\t'

[OPTIONALLY] ENCLOSED BY ''

ESCAPED BY '\\' 

LINES 

TERMINATED BY '\n'


TERMINATED 表示字段分隔 

[OPTIONALLY] ENCLOSED 表示字段用什么字符包括起来,

如果使用了OPTIONALLY则只有CHAR和VERCHAR被包括 ESCAPED 表示当需要转义时用什么作为转义字符 

LINES TERMINATED 表示每行记录之间用什么分隔


http://www.cnblogs.com/xh831213/archive/2012/04/10/2439886.html