SQL Plus®: Quick Reference Release 10.2
SQL Plus®: Quick Reference Release 10.2
Quick Reference
Release 10.2
B14356-01
June 2005
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. Accessibility
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 more
information, visit the Oracle Accessibility Program Web site at
http://www.oracle.com/accessibility/.
1
Accessibility of Code Examples in Documentation
Screen readers may not always correctly read the code examples in this
document. The conventions for writing code require that closing braces should
appear on an otherwise empty line; however, some screen readers may not
always read a line of text that consists solely of a bracket or brace.
2
{EXIT | QUIT} [SUCCESS | FAILURE | WARNING | n | variable
| :BindVariable] [COMMIT | ROLLBACK]
*GET [FILE] file_name[.ext] [LIST | NOLIST]
HELP | ? [topic]
*HO[ST] [command]
*I[NPUT] [text]
L[IST] [n | n m | n * | n LAST | * | * n | * LAST | LAST]
*PASSW[ORD] [username]
PAU[SE] [text]
PRI[NT] [variable ...]
PRO[MPT] [text]
{QUIT | EXIT} [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 [type]]
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]}
XQUERY xquery_statement
*Commands not available in iSQL*Plus.
3
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
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.
4
Navigation Path Purpose
Preferences > To change options which affect output formatting,
System Configuration script execution and database administration.
Preferences > To change your Oracle database password.
Change Password
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.
5
In iSQL*Plus, commits or rolls back all pending changes, stops processing the
current iSQL*Plus script and returns focus to the Workspace. In iSQL*Plus, click
the Logout button to log out of Oracle.
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.
6
Use the following command to access the help system.
HELP | ? [topic]
Accesses the command-line help system. Enter HELP INDEX or ? INDEX for a
list of topics. In iSQL*Plus, you can also click the Help button to display
iSQL*Plus online help. You can view SQL*Plus resources at
http://www.oracle.com/technology/tech/sql_plus/ and the Oracle
Database Library at
http://www.oracle.com/technology/documentation.
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.
7
INPUT is not available 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
8
contain both a comment and a command). SQL*Plus does not interpret the
comment as a command.
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.
9
UNDEF[INE] variable ...
Deletes one or more substitution variables that you defined either explicitly (with
the DEFINE command) or implicitly (with a START command argument).
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.
10
Formatting Query Results
Use the following commands to format, store and print your query results.
11
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.
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:
12
Element Examples Description
9 9999 Displays a value with the number of digits specified by
the number of 9s. Value has a leading space if positive,
a leading minus sign if negative. Blanks are displayed
for leading zeroes. A zero (0) is displayed for a value of
zero.
B B9999 Displays blanks for the integer part of a fixed-point
number when the integer part is zero, regardless of
zeros in the format model.
C C999 Displays the ISO currency symbol in the specified
position.
D 99D99 Displays the decimal character to separate the integral
and fractional parts of a number.
EEEE 9.999EEEE Displays value in scientific notation (format must
contain exactly four "E"s).
G 9G999 Displays the group separator in the specified positions
in the integral part of a number.
L L999 Displays the local currency symbol in the specified
position.
MI 9999MI Displays a trailing minus sign after a negative value.
Display a trailing space after a positive value.
PR 9999PR Displays a negative value in <angle brackets>.
Displays a positive value with a leading and trailing
space.
RN RN Displays uppercase Roman numerals.
rn rn Displays lowercase Roman numerals.
Value can be an integer between 1 and 3999.
S S9999 Displays a leading minus or plus sign.
9999S Displays a trailing minus or plus sign.
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.
13
Function Computes Applies to Datatypes
COU[NT] Count of non-null values All types
14
BOLD
CE[NTER]
COL n
FORMAT text
LE[FT]
R[IGHT]
S[KIP] [n]
TAB n
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.
XQUERY xquery_statement
Allows you to run an XQuery from SQL*Plus.
15
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.
16
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.
17
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 | UNL[IMITED]}] [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}
*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}
SET XQUERY BASEURI {text}
SET XQUERY ORDERING {UNORDERED | ORDERED | DEFAULT}
SET XQUERY NODE {BYVALUE | BYREFERENCE | DEFAULT}
SET XQUERY CONTEXT {text}
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]
18
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
XQUERY
19
20