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

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22664653/viewspace-688864/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/22664653/viewspace-688864/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值