日期:2014-05-16  浏览次数:21353 次

mysql远程查询指定分隔符 结果输出
mysql客户端在机子a上,server在机子b上。现在需要在a上远程查询b中的表,指定分隔符将表中的域分割,结果输出到a上的一个文件中。请问大侠们sql语句怎么写
试过这样的一个语句:
/usr/bin/mysql -uroot -p123456 -P5029 -h 10.11.200.79 -D ib_2012101724 -N -e"select * from cpc limit 1000 into outfile 'new' fields terminated by '\3'" 
但是new file是在远程机子上的


------解决方案--------------------
试试mysqldump的这几个选项

--fields-terminated-by=name 
Fields in the output file are terminated by the given
string.
--fields-enclosed-by=name 
Fields in the output file are enclosed by the given
character.
--fields-optionally-enclosed-by=name 
Fields in the output file are optionally enclosed by the
given character.
--fields-escaped-by=name 
Fields in the output file are escaped by the given
character.

------解决方案--------------------
mysqldump -T
------解决方案--------------------
/usr/bin/mysql -uroot -p123456 -P5029 -h 10.11.200.79 -D ib_2012101724 -N -e"select * from cpc limit 1000 " > new.txt