set feedback off :主要是关闭通过sqlplus 检索出来的结果最下面一般会有一个" 8 row selected"的提示 这个是用于关闭它的
set echo on | off :这个也是在掉用脚本后屏幕是否输出sql语句以及sqlplus语句的设置选项
With echo it is possible to control if echoing of SQL statements and SQL*Plus commands is enabled or not.
If echo is set to off, SQL statements that are run will not be displayed while setting echo to on will display them.
set echo on
set term off
调用@a.sql 不会显示任何信息
set echo on
set term on
调用 @a.sql 会显示sql statement 以及 result set
set echo off
set term on
调用 @a.sql 不显示 sql statement 显示 result set
set term off: 官方解释To spool output (generated by commands in a script) without displaying the output on the screen, use SET TERMOUT OFF. SET TERMOUT OFF does not affect output from commands run interactively.
another:
When people speak of writing SQL*Plus output to a file, the termspool is often used as a verb. You are said to bespooling your output to a file. The SPOOL command is used for this purpose, and you will need to use it twice, once to turn spooling on and again to turn it off.
可以这么理解:spool命令是把screen上所有的信息都显示输出到指定文件,如果这个信息是由于调用脚本命令(@a.sql)而生成的信息,那么把 set term off 设置完成后,是不会显示到屏幕上的,
但是如果这个信息产生是来自交互式的命令行,那么仍然产生(select * from cat;)。
通过做实验知道实际这个set term off 设定后所有脚本调用的结果都不会输出到屏幕,与spool也没关系,只不过一般常用如下这种形式而已
set term off
spool 2010.log
@a.sql
spool off
- SQL> set term on
- SQL> spool 1.log
- SQL> set term off
- SQL> @a.sql
- SQL> spool off
- SQL> @a.sql
- SQL> set term on
- SQL> @a.sql
- SP2-0734: unknown command beginning "SQL> selec..." - rest of line ignored.
- SP2-0734: unknown command beginning "TABLE_NAME..." - rest of line ignored.
- SQL> set term off
- SQL> select * from cat;
- TABLE_NAME TABLE_TYPE
- ------------------------------ -----------
- TEST1 TABLE
- BIN$gAUc/z3amqfgQKjAFQp1bA==$0 TABLE
- EMPLOYEE TABLE
顺便说一下 linux一般常用 sqlplus user/pswd @script.sql 这种命令 ,好处是这样每次就不会因为以前设定的sqlplus格式而影响当前脚本设定的格式,还有如果是为了安全考虑不把用户名和密码写在脚本里面的话,那么可以这样建立一个Ops$reporters的oracle用户,当然这个reporters在unix或者linux系统上也有该用户,然后让他执行 sqlplus / @scripts 然后手动的输入进入数据的用户名以及密码就ok
From:http://blog.youkuaiyun.com/zhoubo200/article/details/5313947