[摘] SQLPLUS Syntax

时间:2022-09-09 02:58:09

You use the SQLPLUS command at the operating system prompt to start
command-line SQL*Plus:
SQLPLUS [ [Options] [Logon] [Start] ]

Options has the following syntax:
[-H[ELP]|-V[ERSION] [-C[OMPATIBILITY]] [-F[AILOVER]] [-L[OGON]] [-M[ARKUP] markup_option] [-R[ESTRICT] {1|2|3}] [-S[ILENT]]]

MARKUP option:
HTML [ON|OFF] [HEAD text] [BODY text] [TABLE text] [ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}]

Logon has the following syntax:
{username[/password][@connect_identifier]| / } [AS {SYSOPER|SYSDBA|SYSASM}]|/NOLOG

HELP Option
-H[ELP]
Displays the usage and syntax for the SQLPLUS command, and then returns control to the operating system.

VERSION Option
-V[ERSION]
Displays the current version and level number for SQL*Plus, and then returns control to the operating system.

COMPATIBILITY Option
-C[OMPATIBILITY] {x.y[.z]
Sets the value of the SQLPLUSCOMPATIBILITY system variable to the SQL*Plus release specified by x.y[.z]. Where x is the version number, y is the release number, and z is the update number. For example, 9.0.1 or 10.2. For more information, see the SET

FAILOVER Option
-F[AILOVER]
Enables SQL*Plus to receive FAN events when connected to a Real Application Cluster (RAC) database. In this mode a service or instance failure is transparently handled with transaction status messages if applicable.

LOGON Option
-L[OGON]
Specifies not to reprompt for username or password if the initial connection does not succeed. This can be useful in operating system scripts that must either succeed or fail and you don't want to be reprompted for connection details if the database server is not running.

MARKUP Options
-M[ARKUP]
You can use the MARKUP option to generate a complete stand alone web page from your query or script.

HTML [ON|OFF]
HTML is a mandatory MARKUP argument which specifies that the type of output to be generated is HTML. The optional HTML arguments, ON and OFF, specify whether or not to generate HTML output. The default is OFF.

MARKUP HTML ON generates HTML output using the specified MARKUP options. You can turn HTML output ON and OFF as required during a session. The default is OFF.

RESTRICT Option
-R[ESTRICT] {1|2|3}
Enables you to disable certain commands that interact with the operating system.
(EDIT,GET,HOST,SAVE,SPOOL,START, @, @@,STORE)

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

Logon
username[/password]
Represent the username and password with which you wish to start SQL*Plus and connect to Oracle Database.
Warning: Including your password in plain text is a security risk. You can avoid this risk by omitting the password, and entering it only when the system prompts for it.

/
Represents a default logon using operating system authentication. You cannot enter a connect identifier if you use a default logon. In a default logon, SQL*Plus typically attempts to log you in using the username OPS$name, where name is your operating system username. Note that the prefix "OPS$" can be set to any other string of text. For example, you may wish to change the settings in your INIT.ORA parameters file to LOGONname or USERIDname. See the Oracle Database Administrator's Guide for information about operating system authentication.

AS {SYSOPER|SYSDBA|SYSASM}
The AS clause enables privileged connections by users who have been granted SYSOPER, SYSDBA or SYSASM system privileges.

/NOLOG
Establishes no initial connection to Oracle Database. Before issuing any SQL commands, you must issue a CONNECT command to establish a valid logon. Use /NOLOG when you want to have a SQL*Plus script prompt for the username, password, or database specification. The first line of this script is not assumed to contain a logon.