【小技巧】sqlplus去掉欢迎信息和提示信息,静默模式(silent option)

原创
2016/12/26 14:52
阅读数 1.3K

每次登陆sqlplus,都会有提示信息,如下:

SQL*Plus: Release 11.1.0.6.0 - Production on Mon Dec 26 14:21:01 2016
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Release 11.1.0.6.0 - Production

在shell中与sqlplus交互时,这些提示信息往往会破坏数据格式。

比如用spool导出数据的时候,不希望显示这些提示信息。

好在sqlplus提供了一个静默选项,关闭所有提示信息。

SILENT Option

-S[ILENT]

Suppresses all SQL*Plus information and prompt messages, including the command prompt, the echoing of commands, and the banner normally displayed when you start SQL*Plus. If you omit username or password, SQL*Plus prompts for them, but the prompts are not visible! Use SILENT to invoke SQL*Plus within another program so that the use of SQL*Plus is invisible to the user.

SILENT is a useful mode for creating reports for the web using the USQLPLS -MARKUP command inside a CGI script or operating system script. The SQL*Plus banner and prompts are suppressed and do not appear in reports created using the SILENT option.

翻译:

静默选项 (-S)

sqlplus -S user/passwd@tns

此选项用来抑制所有SQL*Plus信息和提示信息,包含命令行提示(SQL>),命令回显信息(相当于echo off),和通常在你登陆时显示的提示信息。如果你登陆时省略了用户名和密码,SQL*Plus会有提示,但是在静默模式下,提示信息是看不见的。在其他程序里用静默模式调用 SQL*Plus,这个用户是看不到SQL*Plus的使用情况的。

静默模式是一个非常有用的模式,例如在CGI脚本或者shell脚本里,用SQLPLUS 的MARKUP命令选项来创建基于web的报告。 SQL*Plus的欢迎信息和提示信息被移除,就不会显示在用静默选项创建的报告里了。

补充:

When SQL*Plus starts, and after CONNECT commands, the site profile
(e.g. $ORACLE_HOME/sqlplus/admin/glogin.sql) and the user profile
(e.g. login.sql in the working directory) are run.  The files may
contain SQL*Plus commands.

当 SQL*Plus启动的时候,在connect命令之后,系统配置文件(例如:e.g. $ORACLE_HOME/sqlplus/admin/glogin.sql)和用户配置文件(例如:工作目录下的login.sql)会自动运行。这些文件里可能会包含一些命令。

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部