由 wukaiqiang创建, 最后修改于大约1分钟以前
MySQL实现Oracle的spool功能

Oracle中:

sqlplus> Spool C:\temp\table_names
sqlplus> select table_name from user_tables;
sqlplus> spool off;

MySQL中:

mysql> tee c:\trash\qwe.txt
mysql> show tables;
mysql> notee

C:MySQL\MySQL Server\bin>mysql -u root -p --tee=c:\trash\qwe.txt
...
mysql> notee

oracle 下spool的使用

不回显结果到屏幕

set linesize 1000
set pagesize 0
set echo off
set heading off
set feedback off
set colsep ","
set trims ON
set term off
set trimout on
spool '/home/oracle/test1_2023081601.csv'
@test1.sql
spool '/home/oracle/test2_2023081602.csv'
@test2.sql
spool off;
exit;

其中 test1.sql和test2.sql中保存sql语句

如遇乱码问题,检查环境变量.bash_profile

NLS_LANG="american_america".AL32UTF8

export NLS_LANG

标签: none

评论已关闭