SQL*Plus Quick Reference Release 8.1.7 Part Number A82951-01 |
|
September 2000
Part No. A82951-01
This Quick Reference shows the syntax for SQL*Plus commands. For detailed information on each command, refer to the SQL*Plus User's Guide and Reference.
This Quick Reference discusses the following topics:
The following two tables describe the notation and conventions for command syntax used in this Quick Reference.
Other words are explained where used if their meaning is not given by context.
Enter other punctuation marks where shown in the command syntax.
Use the following commands to log in to and out of SQL*Plus.
where option has the following syntax:
- | -? | [ [-M[ARKUP] "mark_options"] [-R[ESTRICT] {1|2|3}] [-S[ILENT]] ]
where mark_options has the following syntax:
HTML [ON|OFF] [HEAD text] [BODY text] [TABLE text] [ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}]
where logon has the following syntax:
{username[/password][@connect_identifier]|/} [AS {SYSOPER|SYSDBA}] |/NOLOG
and where start has the following syntax:
@file_name[.ext] [arg ...]
Commits all pending changes, terminates SQL*Plus, and returns control to the operating system.
STARTUP [FORCE] [RESTRICT] [PFILE=
filename
] [EXCLUSIVE]
[PARALLEL [RETRY]] [SHARED [RETRY]]
[MOUNT [
dbname
] |
OPEN [
open_options
] [
dbname
] | NOMOUNT
]
where open_options has the following syntax:
READ {ONLY | WRITE [RECOVER]} | RECOVER
Starts an Oracle instance with several options, including mounting and opening a database.
Shuts down a currently running Oracle instance, optionally closing and dismounting a database.
Use the following commands to execute and collect timing statistics on SQL commands and PL/SQL blocks.
Executes the SQL command or PL/SQL block currently stored in the SQL buffer. Does not list the command.
Executes a single PL/SQL statement.
Lists and executes the SQL command or PL/SQL block currently stored in the SQL buffer.
Records timing data for an elapsed period of time, lists the current timer's name and timing data, or lists the number of active timers.
Use the following command to access the help system.
Accesses help on SQL*Plus commands.
Use the following command to execute host operating system commands.
Executes a host operating system command without leaving SQL*Plus.
Use the following commands to edit SQL commands and PL/SQL blocks.
Adds specified text to the end of the current line in the SQL buffer. To separate text from the preceding characters with a space, enter two spaces between APPEND and text. To append text that ends with a semicolon, end the command with two semicolons (SQL*Plus interprets a single semicolon as a command terminator).
Changes text on the current line in the SQL buffer. You can use any non-alphanumeric character such as "/" or "!" as a sepchar. You can omit the space between CHANGE and the first sepchar.
Deletes one or more lines of the buffer ("*" indicates the current line). You can omit the space between DEL and n or *, but not between DEL and LAST. Enter DEL with no clauses to delete the current line of the buffer.
Adds one or more new lines of text after the current line in the buffer.
Lists one or more lines of the buffer ("*" indicates the current line). You can omit the space between LIST and n or *, but not between LIST and LAST. Enter LIST with no clauses to list all lines.
Use the following commands to create and modify command files.
Runs the specified command file. Specified arguments are substituted for &1, &2, and so on.
Runs the specified nested command file.
Invokes a host operating system text editor on the contents of the specified file or on the contents of the SQL buffer. To edit the buffer contents, omit the file name.
Loads a host operating system file into the SQL buffer.
Begins a comment in a command file. The REMARK command must appear at the beginning of a line, and the comment ends at the end of the line (a line cannot contain both a comment and a command). SQL*Plus does not interpret the comment as a command.
Saves the contents of the buffer into a host operating system file (a command file).
Saves the attributes of the current SQL*Plus environment in a host operating system file (a command file).
Executes the contents of the specified command file. Specified arguments are substituted for &1, &2, and so on.
WHENEVER OSERROR {EXIT [SUCCESS|FAILURE|
n
|
variable
|:
BindVariable
] [COMMIT|ROLLBACK]|CONTINUE
[COMMIT|ROLLBACK|NONE]}
Exits SQL*Plus if an operating system error occurs (such as a file I/O error).
WHENEVER SQLERROR {EXIT [
SUCCESS|FAILURE|WARNING|
n
|
variable
|:
BindVariable
] [
COMMIT|ROLLBACK]|CONTINUE [COMMIT|ROLLBACK|
NONE]}
Exits SQL*Plus if a SQL command or PL/SQL block generates an error.
Use the following commands to write interactive commands.
ACC[EPT]
variable
[NUM[BER]|
CHAR|DATE] [FOR[MAT]
format
]
[DEF[AULT]
default
] [PROMPT
text
|
NOPR[OMPT]] [HIDE]
Reads a line of input and stores it in a given user variable.
Specifies a user variable and assigns it a CHAR value. Alternatively, lists the value and variable type of a single variable or all variables.
Displays an empty line followed by a line containing text, then waits for the user to press [Return]. Alternatively, displays two empty lines and waits for the user's response.
Sends the specified message or a blank line to the user's screen.
Deletes given user variables that you defined either explicitly (with the DEFINE command) or implicitly (with an argument to the START command).
Use the following commands to create and display bind variables.
Displays the current values of bind variables.
VAR[IABLE] [
variable
{NUMBER|CHAR|CHAR (
n
)|NCHAR
|NCHAR (
n
)|VARCHAR2 (
n
)| NVARCHAR2 (
n
)
|CLOB|NCLOB|REFCURSOR}]
Declares a bind variable which can then be referenced in PL/SQL. If no arguments are supplied, VARIABLE lists all declared bind variables.
Use the following symbols to create substitution variables and parameters for use in command files.
Specifies a parameter in a command file you run using the START command. START substitutes values you list after the command file name as follows: the first for &1, the second for &2, and so on.
Indicates a substitution variable in a SQL or SQL*Plus command. SQL*Plus substitutes the value of the specified user variable for each substitution variable it encounters. If the user variable is undefined, SQL*Plus prompts you for a value each time an "&" variable is found, and the first time an "&&" variable is found.
Terminates a substitution variable followed by a character that would otherwise be part of the variable name.
Use the following commands to format, store and print your query results.
Specifies display attributes for a given object attribute, or lists the current display attributes for a single attribute or for all attributes; option represents one of the following clauses:
ALI[AS] alias CLE[AR] FOR[MAT] format LIKE {type_name.attribute_name|alias} ON|OFF
Specifies where and how formatting will change in a report (for example, skipping a line each time a given column value changes). Enter BREAK with no clauses to list the current BREAK definition.
Where report_element has the following syntax:
{column|expr|ROW|REPORT}
and where action has the following syntax:
[SKI[P] n|[SKI[P]] PAGE] [NODUP[LICATES]|DUP[LICATES]]
Places and formats the specified title at the bottom of each report page, or lists the current BTITLE definition. See TITLE for additional information on valid printspec clauses.
Resets or erases the current value or setting for the specified option; option represents one of the following clauses:
BRE[AKS] BUFF[ER] COL[UMNS] COMP[UTES] SCR[EEN] SQL TIMI[NG]
Specifies the display attributes for a given column, such as text for the column heading, or formats for CHAR, NCHAR, VARCHAR2 (VARCHAR), NVARCHAR2 (NCHAR VARYING), LONG, CLOB, NCLOB and NUMBER data; option represents one of the following clauses:
ALI[AS] alias CLE[AR] ENTMAP {ON|OFF} FFOLD_A[FTER] FOLD_B[EFORE] FOR[MAT] format HEA[DING] text JUS[TIFY] {L[EFT]|C[ENTER]|C[ENTRE]|R[IGHT]} LIKE {expr|alias} NEWL[INE] NEW_V[ALUE] variable NOPRI[NT]|PRI[NT] NUL[L] text OLD_V[ALUE] variable ON|OFF WRA[PPED]|WOR[D_WRAPPED]|TRU[NCATED]
Enter COLUMN followed by column or expr and no other clauses to list the current display attributes for only the specified column or expression. Enter COLUMN with no clauses to list all current column display attributes.
Enter COLUMN [{column |expr} FORMAT format] where the format element specifies the display format for the column.
To change the display format of a NUMBER column, use FORMAT followed by one of the elements in the following table:
COMP[UTE] [
function
[LAB[EL]
text
] ...
OF {
expr
|
column
|
alias
} ...
ON {
expr
|
column
|
alias
|REPORT|ROW} ...]
Calculates and prints summary lines, using various standard computations, on subsets of selected rows, or lists all COMPUTE definitions. The following table lists valid functions. All functions except NUMBER apply to non-null values only. COMPUTE functions are always executed in the following sequence AVG, COUNT, MINIMUM, MAXIMUM, NUMBER, SUM, STD, VARIANCE.
Places and formats a specified report footer at the bottom of each report, or lists the current REPFOOTER definition. See REPHEADER for additional information on valid printspec clauses.
Places and formats a specified report header at the top of each report, or lists the current REPHEADER definition. Use one of the following clauses in place of printspec:
COL n S[KIP] [n] TAB n LE[FT] CE[NTER] R[IGHT] BOLD FORMAT text
Stores query results in an operating system file and, optionally, sends the file to a printer. OFF stops spooling. OUT stops spooling and sends the file to your host computer's standard (default) printer. Enter SPOOL with no clauses to list the current spooling status. If no file extension is given, the default extension, .lst or .lis, is used
Places and formats a specified title at the top of each report page, or lists the current TTITLE definition. Use one of the following clauses in place of printspec:
COL n S[KIP] [n] TAB n LE[FT] CE[NTER] R[IGHT] BOLD FORMAT text
Use the following commands to access and copy data between tables on different databases.
where logon requires the following syntax:
username[/password][@connect_identifier] | /
Connects a given username to Oracle. If you omit connect_identifier, connects you to the default database. If you omit username and/or password, SQL*Plus prompts you for them. CONNECT followed by a slash (/) connects you using a default (OPS$) logon.
Commits pending changes to the database and logs the current username off Oracle, but does not exit SQL*Plus.
COPY {FROM
database | TO
database | FROM
database TO
database} {APPEND|CREATE|INSERT|REPLACE}
destination_table[(
column,
column,
column, ...)] USING
query
where database has the following syntax:
username[/
password]
@connect_identifier
Copies data from one Oracle database to a table in another. APPEND, CREATE, INSERT or REPLACE specifies how COPY treats the existing copy of the destination table (if it exists). USING query identifies the source table and determines which rows and columns COPY copies from it.
Allows you to change a password without echoing the password on the terminal.
Starts or stops automatic archiving on online redo log files, manually (explicitly) archives specified redo log files, or displays information about redo log files.
Lists the column definitions for the specified table, view or synonym or the specifications for the specified function or procedure.
where the general clause has the following syntax:
[AUTOMATIC][FROM location] {[STANDBY] DATABASE [ [UNTIL {CANCEL | CHANGE integer | TIME date} | USING BACKUP CONTROLFILE]...] | STANDBY {DATAFILE datafilename [, DATAFILE datafilename...] | TABLESPACE tablespace [, TABLESPACE tablespace ...]} UNTIL [CONSISTENT] [WITH] CONTROLFILE | TABLESPACE tablespace [, tablespace ...] | DATAFILE datafilename [, datafilename ...] | LOGFILE filename | CONTINUE [DEFAULT] | CANCEL}
and where the managed clause has the following syntax:
MANAGED STANDBY DATABASE {TIMEOUT integer | CANCEL [IMMEDIATE]}
and where the parallel clause has the following syntax:
PARALLEL [integer] | NOPARALLEL
Performs media recovery on one or more tablespaces, one or more datafiles, or the entire database.
Sets a system variable to alter the SQL*Plus environment for your current session, such as setting the display width for NUMBER data or the number of lines per page. Enter a system variable followed by a value as shown below:
APPI[NFO]{ON|OFF|text} ARRAY[SIZE] {15|n} AUTO[COMMIT] {ON|OFF|IMM[EDIATE]|n} AUTOP[RINT] {ON|OFF} AUTORECOVERY {ON|OFF] AUTOT[RACE] {ON|OFF|TRACE[ONLY]} [EXP[LAIN]] [STAT[ISTICS]] BLO[CKTERMINATOR] {.|c} CMDS[EP] {;|c|ON|OFF} COLSEP {_|text} COM[PATIBILITY] {V7|V8|NATIVE} CON[CAT] {.|c|ON|OFF} COPYC[OMMIT] {0|n} COPYTYPECHECK {ON|OFF} DEF[INE] {'&'|c|ON|OFF} DESCRIBE [DEPTH {1|n|ALL}][LINENUM {ON|OFF}][INDENT {ON|OFF}] ECHO {ON|OFF} EDITF[ILE] file_name[.ext] EMB[EDDED] {ON|OFF} ESC[APE] {\|c|ON|OFF} FEED[BACK] {6|n|ON|OFF} FLAGGER {OFF|ENTRY|INTERMED[IATE]|FULL} FLU[SH] {ON|OFF} HEA[DING] {ON|OFF} HEADS[EP] {||c|ON|OFF} INSTANCE [instance_path|LOCAL] LIN[ESIZE] {80|n} LOBOF[FSET] {n|1} LOGSOURCE [pathname] LONG {80|n} LONGC[HUNKSIZE] {80|n} MARK[UP] HTML [ON|OFF] [HEAD text] [BODY text] [TABLE text] [ENTMAP {ON|OFF}] [SPOOL {ON|OFF}] [PRE[FORMAT] {ON|OFF}] NEWP[AGE] {1|n|NONE} NULL text NUMF[ORMAT] format NUM[WIDTH] {10|n} PAGES[IZE] {24|n} PAU[SE] {ON|OFF|text} RECSEP {WR[APPED]|EA[CH]|OFF} RECSEPCHAR {_|c} SERVEROUT[PUT] {ON|OFF} [SIZE n] [FOR[MAT] {WRA[PPED] |WOR[D_WRAPPED]|TRU[NCATED]}] SHIFT[INOUT] {VIS[IBLE]|INV[ISIBLE]} SHOW[MODE] {ON|OFF} SQLBL[ANKLINES] {ON|OFF} SQLC[ASE] {MIX[ED]|LO[WER]|UP[PER]} SQLCO[NTINUE] {> |text} SQLN[UMBER] {ON|OFF} SQLPRE[FIX] {#|c} SQLP[ROMPT] {SQL>|text} SQLT[ERMINATOR] {;|c|ON|OFF} SUF[FIX] {SQL|text} TAB {ON|OFF} TERM[OUT] {ON|OFF} TI[ME] {ON|OFF} TIMI[NG] {ON|OFF} TRIM[OUT] {ON|OFF} TRIMS[POOL] {ON|OFF} UND[ERLINE] {-|c|ON|OFF} VER[IFY] {ON|OFF} WRA[P] {ON|OFF}
Lists the value of a SQL*Plus system variable. Enter any system variable set by the SET command in place of system_variable. Use one of the following terms or clauses in place of option:
system_variable ALL BTI[TLE] ERR[ORS] [{FUNCTION|PROCEDURE|PACKAGE|PACKAGE BODY |TRIGGER|VIEW|TYPE|TYPE BODY} [schema.]name] LNO PARAMETERS [parameter_name] PNO REL[EASE] REPF[OOTER] REPH[EADER] SGA SPOO[L] SQLCODE TTI[TLE] USER
SQL commands were formerly documented in SQL*Plus documentation. You should now refer to the Oracle8i SQL Reference for full documentation of these commands and clauses. Below is a list of major SQL commands:
ALTER |
LOCK TABLE |
ANALYZE |
NOAUDIT |
AUDIT |
RENAME |
COMMENT |
REVOKE |
COMMIT |
ROLLBACK |
CREATE |
SAVEPOINT |
DELETE |
SELECT |
DROP |
SET ROLE |
EXPLAIN |
SET TRANSACTION |
GRANT |
TRUNCATE |
INSERT |
UPDATE |
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|