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

每次登錄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交互時,這些提示信息每每會破壞數據格式。web

好比用spool導出數據的時候,不但願顯示這些提示信息。sql

好在sqlplus提供了一個靜默選項,關閉全部提示信息。shell

SILENT Option

-S[ILENT]apache

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.bash

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.app

翻譯:ide

靜默選項 (-S)spa

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)會自動運行。這些文件裏可能會包含一些命令。

相關文章
相關標籤/搜索