Oracle Quick Reference
Oracle Quick Reference
Quick Reference
Release 10.1
December 2003
Part No. B12171-01
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may
be trademarks of their respective owners.
Copyright © 1996, 2003 Oracle Corporation.
All Rights Reserved.
Conventions for Command Syntax
The following two tables describe the notation and conventions for
command syntax used in this Quick Reference.
Table 2 Punctuation
Feature Example Explanation
vertical bar | Separates alternative syntax elements that may be
optional or mandatory.
brackets [ON | OFF] One or more optional items. If two items appear
separated by |, enter one of the items. Do not enter the
brackets or |.
braces {ON | OFF} A choice of mandatory items; enter one of the items. Do
not enter the braces or |.
underlining {ON | OFF} A default value; if you enter nothing, SQL*Plus assumes
the underlined value.
ellipsis n ... Preceding items may be repeated any number of times.
2
Documentation Accessibility
Our goal is to make Oracle products, services, and supporting
documentation accessible, with good usability, to the disabled community.
To that end, our documentation includes features that make information
available to users of assistive technology. This documentation is available in
HTML format, and contains markup to facilitate access by the disabled
community. Standards will continue to evolve over time, and Oracle is
actively engaged with other market-leading technology vendors to address
technical obstacles so that our documentation can be accessible to all of our
customers. For additional information, visit the Oracle Accessibility
Program Web site at
http://www.oracle.com/accessibility/
3
Alphabetic List of SQL*Plus Commands
@{url | file_name [.ext]} [arg ...]
@@ { url | file_name[.ext] } [arg ...]
/ (slash)
ACC[EPT] variable [NUM[BER] | CHAR | DATE | BINARY_FLOAT | BINARY_DOUBLE]
[FOR[MAT] format] [DEF[AULT] default] [PROMPT text | NOPR[OMPT]] [HIDE]
*A[PPEND] text
ARCHIVE LOG {LIST | STOP} | {START | NEXT | ALL | integer} [TO destination ]
ATTRIBUTE [type_name.attribute_name [option...]]
BRE[AK] [ON report_element [action [action]]] ...
BTI[TLE] [printspec [text | variable] ...] | [ON | OFF]
*C[HANGE] sepchar old [sepchar [new [sepchar]]]
CL[EAR] option ...
COL[UMN] [{column | expr} [option ...]]
COMP[UTE] [function [LAB[EL] text] ... OF {expr | column | alias} ...ON {expr | column | alias
| REPORT | ROW} ...]
CONN[ECT] [{logon | /} [AS {SYSOPER | SYSDBA}]]
COPY {FROM database | TO database | FROM database TO database} {APPEND |
CREATE | INSERT | REPLACE} destination_table[(column, column, column, ...)] USING
query
DEF[INE] [variable ] | [variable = text]
*DEL [n | n m | n * | n LAST | * | * n | * LAST | LAST]
DESC[RIBE] {[schema .]object[@connect_identifier]}
DISC[ONNECT]
*ED[IT] [file_name[.ext]]
EXEC[UTE] statement
{EXIT | QUIT} [SUCCESS | FAILURE | WARNING | n | variable
| :BindVariable] [COMMIT | ROLLBACK]
*GET [FILE] file_name[.ext] [LIS[T] | NOL[IST]]
HELP | ? [topic]
*HO[ST] [command]
*I[NPUT] [text]
4
L[IST] [n | n m | n * | n LAST | * | * n | * LAST | LAST]
*PASSW[ORD] [username]
PAU[SE] [text]
PRI[NT] [variable ...]
PRO[MPT] [text]
{EXIT | QUIT} [SUCCESS | FAILURE | WARNING | n | variable
| :BindVariable] [COMMIT | ROLLBACK]
RECOVER {general | managed | BEGIN BACKUP | END BACKUP}
REM[ARK]
REPF[OOTER] [PAGE] [printspec [text | variable ] ...] | [ON | OFF]
REPH[EADER] [PAGE] [printspec [text | variable] ...] | [ON | OFF]
R[UN]
*SAV[E] [FILE] file_name[.ext] [CRE[ATE] | REP[LACE] | APP[END]]
SET system_variable value
SHO[W] [option]
SHUTDOWN [ABORT | IMMEDIATE | NORMAL | TRANSACTIONAL [LOCAL]]
*SPO[OL] [filename[.ext] [CRE[ATE] | REP[LACE] | APP[END]] | OFF | OUT]
STA[RT] { url | file_name[.ext] } [arg ...]
STARTUP options | upgrade_options
*STORE {SET} file_name[.ext] [CRE[ATE] | REP[LACE] | APP[END]]
TIMI[NG] [START text | SHOW | STOP]
TTI[TLE] [printspec [text | variable] ...] | [ON | OFF]
UNDEF[INE] variable ...
VAR[IABLE] [variable {NUMBER | CHAR | CHAR (n [CHAR | BYTE]) | NCHAR | NCHAR (n)
| VARCHAR2 (n [CHAR | BYTE])| NVARCHAR2(n) | CLOB | NCLOB | REFCURSOR
| BINARY_FLOAT | BINARY_DOUBLE}]
WHENEVER OSERROR {EXIT [SUCCESS | FAILURE | n | variable | :BindVariable]
[COMMIT | ROLLBACK] | CONTINUE[COMMIT | ROLLBACK | NONE]}
WHENEVER SQLERROR {EXIT [SUCCESS | FAILURE | WARNING | n | variable
| :BindVariable] [COMMIT | ROLLBACK] | CONTINUE [COMMIT | ROLLBACK | NONE]}
*Commands not available in iSQL*Plus.
5
Starting iSQL*Plus
Use the following syntax in your web browser's URL field to display
iSQL*Plus.
http://machine_name.domain:port/isqlplus[/dynamic?UserOpts]
or to start iSQL*Plus with DBA privileges, use:
http://machine_name.domain/isqlplus/dba[/dynamic?DBAOpts]
where UserOpts has the following syntax:
UserLogin | Script | UserLogin&Script
where DBAOpts has the following syntax:
DBALogin | Script | DBALogin&Script
where UserLogin has the following syntax:
userid=username[/password] [@connect_identifier]
where DBALogin has the following syntax:
userid ={username[/password] [@connect_identifier] | / } AS {SYSDBA | SYSOPER}
and where Script has the following syntax:
script=text[&type={url | text}] [&action={execute | load}] [&variable =value. . .]
Examples
To start iSQL*Plus, enter
http://machine_name.domain:port/isqlplus
To start iSQL*Plus with DBA Privileges, enter
http://machine_name.domain:port/isqlplus/dba
6
iSQL*Plus Navigation
The table lists navigation icons used to navigate in iSQL*Plus.
iSQL*Plus Preferences
The table lists preferences that can be set in iSQL*Plus.
Button Purpose
Execute To execute the contents of the Workspace.
Load Script To load a script into the Workspace. The script can be local, or
loaded via HTTP or FTP.
Save Script To save the contents of the Workspace to a local file.
Cancel To interrupt a script during execution.
Next Page To view the next page of results.
Clear To clear the script input and output areas.
7
Starting and Leaving SQL*Plus
Use the following commands to log in to and out of SQL*Plus.
SQLPLUS [[option] [logon] [start]]
where option has the following syntax:
-H[ELP]
| -V[ERSION]
| [ [-C[OMPATIBILITY] x.y[.z]] [-L[OGON]]
[-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:
@{url | file_name [.ext]} [arg ...]
8
Starting Up and Shutting Down a Database
Starting up and shutting down a database requires DBA privileges.
STARTUP options | upgrade_options
where options has the following syntax:
[FORCE] [RESTRICT] [PFILE= filename] [QUIET] [ MOUNT [dbname] |
[ OPEN [open_options] [dbname ] ] | NOMOUNT ]
where open_options has the following syntax:
READ {ONLY | WRITE [RECOVER]} | RECOVER
and where upgrade_options has the following syntax:
[PFILE=filename] {UPGRADE | DOWNGRADE} [QUIET]
Starts an Oracle instance with several options, including mounting and
opening a database.
EXEC[UTE] statement
Executes a single PL/SQL statement or runs a stored procedure.
R[UN]
Lists and executes the most recently executed SQL command or PL/SQL
block which is stored in the SQL buffer. The buffer has no command history
and does not record SQL*Plus commands.
9
TIMI[NG] [START text | SHOW | STOP]
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.
10
DEL [n | n m | n * | n LAST | * | * n | * LAST | LAST]
Deletes one or more lines of the SQL 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.
The buffer has no command history list and does not record SQL*Plus
commands.
DEL is not available in iSQL*Plus.
I[NPUT] [text]
Adds one or more new lines of text after the current line in the SQL buffer.
The buffer has no command history list and does not record SQL*Plus
commands.
INPUT is not available in iSQL*Plus.
11
STA[RT] { url | file_name[.ext] } [arg ...]
Runs the SQL*Plus statements in the specified script. The script can be
called from the local file system or a web server. You can pass values to
script variables in the usual way.
Only the url form is supported in iSQL*Plus.
ED[IT] [file_name[.ext]]
Invokes an 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. The buffer has no command history list and does not record
SQL*Plus commands.
EDIT is not available in iSQL*Plus.
REM[ARK]
Begins a comment in a script. 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.
12
WHENEVER OSERROR {EXIT [SUCCESS | FAILURE | n | variable
| :BindVariable] [COMMIT | ROLLBACK] | CONTINUE [COMMIT | ROLLBACK | NONE]}
Performs the specified action (exits SQL*Plus by default) if an operating
system error occurs (such as a file writing error).
In iSQL*Plus, performs the specified action (stops the current script by
default) and returns focus to the Workspace if an operating system error
occurs.
WHENEVER SQLERROR {EXIT [SUCCESS | FAILURE | WARNING | n | variable
| :BindVariable] [COMMIT | ROLLBACK] | CONTINUE [COMMIT | ROLLBACK | NONE]}
Performs the specified action (exits SQL*Plus by default) if a SQL command
or PL/SQL block generates an error.
In iSQL*Plus, performs the specified action (stops the current script by
default) and returns focus to the Workspace if a SQL command or PL/SQL
block generates an error.
PAU[SE] [text]
Displays the specified text then waits for the user to press RETURN. In
iSQL*Plus, displays the Next Page button which the user must click to
continue.
PRO[MPT] [text]
Sends the specified message or a blank line to the user's screen.
13
Use the following commands to create and display bind variables.
Use the following symbols to create substitution variables and parameters for use in
scripts.
&n
Specifies a parameter in a script you run using the START command.
START substitutes values you list after the script name as follows: the first
for &1, the second for &2, and so on.
&user_variable, &&user_variable
Indicates a substitution variable in a SQL or SQL*Plus command. SQL*Plus
substitutes the value of the specified substitution variable for each
substitution variable it encounters. If the substitution variable is undefined,
SQL*Plus prompts you for a value each time an "&" variable is found, and
the first time an "&&" variable is found.
. (period)
Terminates a substitution variable followed by a character that would
otherwise be part of the variable name.
14
Where option represents one of the following clauses:
ALI[AS] alias
CLE[AR]
FOR[MAT] format
LIKE {type_name.attribute_name|alias}
ON|OFF
15
CL[EAR] option ...
Resets or erases the current value or setting for the specified option.
Where option represents one of the following clauses:
BRE[AKS]
BUFF[ER]
COL[UMNS]
COMP[UTES]
SCR[EEN]
SQL
TIMI[NG]
CLEAR SCREEN is not available in iSQL*Plus.
16
To change the display format of a NUMBER column, use FORMAT
followed by one of the elements in the following table:
17
Element Examples Description
TM TM Displays the smallest number of decimal characters
possible. The default is TM9. Fixed notation is used for
output up to 64 characters, scientific notation for more
than 64 characters. Cannot precede TM with any other
element. TM can only be followed by a single 9 or E
U U9999 Displays the dual currency symbol in the specified
position.
COMP[UTE] [function [LAB[EL] text] ... OF {expr | column | alias} ...ON {expr | column | alias
| REPORT | ROW} ...]
In combination with the BREAK command, calculates and prints summary
lines using various standard computations. It also 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.
18
REPF[OOTER] [PAGE] [printspec [text | variable ] ...] | [ON | OFF]
Places and formats a footer at the bottom of a report, or lists the current
REPFOOTER definition.
Where printspec represents one or more of the following clauses:
BOLD
CE[NTER]
COL n
FORMAT text
LE[FT]
R[IGHT]
S[KIP] [n]
TAB n
19
Accessing Databases
Use the following commands to access and copy data between tables on different
databases.
DISC[ONNECT]
Commits pending changes to the database and logs the current user out of
Oracle, but does not exit SQL*Plus. In SQL*Plus command line, use EXIT or
QUIT to log out of Oracle and return control to your computer's operating
system. In iSQL*Plus, click the Logout button to log out of Oracle.
PASSW[ORD] [username]
Allows you to change a password without displaying it on an input device.
In iSQL*Plus, you can also use the Password screen to change your
password.
20
Miscellaneous
ARCHIVE LOG {LIST | STOP} | {START | NEXT | ALL | integer}[TO destination]
Starts or stops automatic archiving of online redo logs, manually (explicitly)
archives specified redo logs, or displays information about redo log files.
21
| ALL ARCHIVELOG | { ALL | LAST | NEXT } SWITCHOVER} }
[ DISCONNECT [ FROM SESSION ] | { TIMEOUT integer | NOTIMEOUT }
| { NODELAY | DEFAULT DELAY | DELAY integer } | NEXT integer
| { EXPIRE integer | NO EXPIRE } | parallel_clause
| USING CURRENT LOGFILE | UNTIL CHANGE integer
| THROUGH { [ THREAD integer ] SEQUENCE integer
| ALL ARCHIVELOG | { ALL | LAST | NEXT } SWITCHOVER} ]...
where the cancel_clause has the following syntax:
CANCEL [IMMEDIATE] [WAIT | NOWAIT]
where the finish_clause has the following syntax:
[ DISCONNECT [ FROM SESSION ] ] [ parallel_clause ]
FINISH [ SKIP [ STANDBY LOGFILE ] ] [ WAIT | NOWAIT ]
where the parallel_clause has the following syntax:
{ NOPARALLEL | PARALLEL [ integer ] }
Performs media recovery on one or more tablespaces, one or more datafiles,
or the entire database.
Because of possible network timeouts, it is recommended that you use
SQL*Plus command-line, not iSQL*Plus, for long running DBA operations
such as RECOVER.
22
SET CMDS[EP] {; | c | ON | OFF}
SET COLSEP {_ | text}
SET COM[PATIBILITY] {V7 | V8 | NATIVE}
SET CON[CAT] {. | c | ON | OFF}
SET COPYC[OMMIT] {0 | n}
SET COPYTYPECHECK {ON | OFF}
SET DEF[INE] {& | c | ON | OFF}
SET DESCRIBE [DEPTH {1 | n | ALL}] [LINENUM {ON | OFF}] [INDENT {ON | OFF}]
SET ECHO {ON | OFF}
*SET EDITF[ILE] file_name[.ext]
SET EMB[EDDED] {ON | OFF}
SET ESC[APE] {\ | c | ON | OFF}
SET FEED[BACK] {6 | n | ON | OFF}
SET FLAGGER {OFF | ENTRY | INTERMED[IATE] | FULL}
*SET FLU[SH] {ON | OFF}
SET HEA[DING] {ON | OFF}
SET HEADS[EP] { | | c | ON | OFF}
SET INSTANCE [instance_path | LOCAL]
SET LIN[ESIZE] {80 | n} (default is 150 in iSQL*Plus)
SET LOBOF[FSET] {n | 1}
SET LOGSOURCE [pathname]
SET LONG {80 | n}
SET LONGC[HUNKSIZE] {80 | n}
SET MARK[UP] HTML [ON | OFF] [HEAD text] [BODY text] [TABLE text]
[ENTMAP {ON | OFF}] [SPOOL {ON | OFF}] [PRE[FORMAT] {ON | OFF}]
SET NEWP[AGE] {1 | n | NONE}
SET NULL text
SET NUMF[ORMAT] format
SET NUM[WIDTH] {10 | n}
SET PAGES[IZE] {14 | n}
SET PAU[SE] {ON | OFF | text}
SET RECSEP {WR[APPED] | EA[CH] | OFF}
SET RECSEPCHAR { | c}
SET SERVEROUT[PUT] {ON | OFF} [SIZE n] [FOR[MAT] {WRA[PPED]
| WOR[D_WRAPPED] | TRU[NCATED]}]
*SET SHIFT[INOUT] {VIS[IBLE] | INV[ISIBLE]}
*SET SHOW[MODE] {ON | OFF}
*SET SQLBL[ANKLINES] {ON | OFF}
SET SQLC[ASE] {MIX[ED] | LO[WER] | UP[PER]}
*SET SQLCO[NTINUE] {> | text}
*SET SQLN[UMBER] {ON | OFF}
SET SQLPLUSCOMPAT[IBILITY] {x.y[.z]}
*SET SQLPRE[FIX] {# | c}
*SET SQLP[ROMPT] {SQL> | text}
SET SQLT[ERMINATOR] {; | c | ON | OFF}
23
*SET SUF[FIX] {SQL | text}
*SET TAB {ON | OFF}
*SET TERM[OUT] {ON | OFF}
*SET TI[ME] {ON | OFF}
SET TIMI[NG] {ON | OFF}
*SET TRIM[OUT] {ON | OFF}
*SET TRIMS[POOL] {ON | OFF}
SET UND[ERLINE] {- | c | ON | OFF}
SET VER[IFY] {ON | OFF}
SET WRA[P] {ON | OFF}
An asterisk (*) indicates the SET option is not supported in iSQL*Plus.
SHO[W] [option]
Shows the value of a SQL*Plus system variable, or the current SQL*Plus
environment. Enter any system variable set by the SET command in place
of system_variable. SHOW SGA requires a DBA privileged login. 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 | DIMENSION | JAVA CLASS} [schema.]name]
LNO
PARAMETERS [parameter_name]
PNO
RECYC[LEBIN] [original_name]
REL[EASE]
REPF[OOTER]
REPH[EADER]
SGA
SPOO[L] (Not available in iSQL*Plus)
SQLCODE
TTI[TLE]
USER
24