sqlplus 环境下部分set 命令

简介:
由于业务需要导出单个字段的少量数据,设置了脚本来执行,但是结果总是回显在屏幕上,而导致不合适。现将正确的格式的脚本介绍一下。
刚开始自己的在linux执行的脚本中没有set trimspool on 这一设置,导致在linux下有结果回显,而在windows下则符合要求
=============== windows=============
--test.sql 文件内容
set echo off  不显示脚本中的每个sql命令
set feedback off  禁止回显sql命令处理的记录条数(默认为 on)
set term off    禁止显示脚本中命令的执行结果(默认为on)
set heading off 禁止输出标题(默认为on)
set pagesize 0 禁止输出分页
set linesize 1000 设置每行的字符输出个数为1000,放置换行。
set trimout on 去除标准输出每行的行尾空格 默认为off
set trimspool on 去除spool 输出结果中每行的结尾空格 默认为off
spool d:\im_user.txt
select * from t where rownum <50;
--select /*+ use_hash(tu iu)*/ iu.login_id from tmp_user tu ,im_user iu where iu.login_id=tu.tuid and iu.user_status=1;
spool off
set term on
set heading on
set feedback on
set echo on
exit;


C:\Users\aaaa>sqlplus yang/yang
SQL*Plus: Release 11.1.0.6.0 - Production on 星期三 3月 9 16:35:17 2011
Copyright (c) 1982, 2007, Oracle.  All rights reserved.

连接到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
yang@ORACL> @d:\test.sql
yang@ORACL> exit;
================linux=================
#!/bin/sh
#created by yangql @2011-03-09
#parameters
ora_user=aliim
ora_passwd=aliim
sqlplus -s ${ora_user}/${ora_passwd} < set echo off
set feedback off
set term off
set heading off
spool /tmp/im_user.txt

select /*+ use_hash(tu iu)*/ iu.login_id from tmp_user tu ,im_user iu where iu.login_id=tu.tuid and iu.user_status=1;
spool off
set term on
set heading on
set echo on
set feedback on
exit;
EOF

"get_im_user.sh" 20 lines, 407 characters written
oracle@dba-host1:/tmp>./get_im_user.sh

34607
74158
02561
82517
40445
85825
04801
65546
45715
b40384
73865
b52708

相关文章
|
5月前
|
Oracle 关系型数据库 数据库
“sqlplus / as sysdba”执行失败---Win10下,DOS命令添加系统用户到ora_dba用户组
“sqlplus / as sysdba”执行失败---Win10下,DOS命令添加系统用户到ora_dba用户组
38 0
|
SQL Oracle 关系型数据库
|
SQL Oracle 关系型数据库
|
SQL Oracle 关系型数据库
|
SQL Oracle 关系型数据库