oracle/mysql 将查询数据导出到文件中

一、将oracle 查询的数据导入到一个文本文件中
方法一 :通过sql developer 工具导出到xls表中
方法二:通过客户端sqlplus 到一个临时txt文件中再处理
着重讲方法二(在使用场景下方便、快捷)
SQL>spool d:sqlbak.txt;
SQL>select * from table where a>x;
SQL>spool off;
这样刚查询的数据就好在d盘下的 sqlbak.txt 文件中,linux下同理: spool /tmp/sqlbak.txt

二、 将mysql 查询当中的数据导入到一个文本文件txt 中

mysql> select from table into outfile '/tmp/sqlbak.txt';
或者
mysql -uroot -ppassword -Ddbname -e"select
from table where x>y" >/tmp/sqlbak.txt

猜你喜欢

转载自blog.51cto.com/13396187/2361321