SQL Plus
SQL Plus
Quick Reference
Release 8.1.5
February, 1999
Part No. A66735-01
SQL*Plus Quick Reference, Release 8.1.5
Contributors: Larry Baer, Lisa Colston, Roland Kovacs, Karen Denchfield-Masterson, Alison Holloway,
Sanjeev Jhala, Christopher Jones, Anita Lam, Nimish Mehta, Luan Nim, Bud Osterberg, Irene Paradisis,
Richard Rendell, Farokh Shapoorjee, Larry Stevens, Andre Touma
The Programs are not intended for use in any nuclear, aviation, mass transit, medical, or other
inherently dangerous applications. It shall be the licensee’s responsibility to take all appropriate
fail-safe, backup, redundancy and other measures to ensure the safe use of such applications if the
Programs are used for such purposes, and Oracle disclaims liability for any damages caused by such
use of the Programs.
The Programs (which include both the software and documentation) contain proprietary information of
Oracle Corporation; they are provided under a license agreement containing restrictions on use and
disclosure and are also protected by copyright, patent, and other intellectual and industrial property
laws. Reverse engineering, disassembly, or decompilation of the Programs is prohibited.
The information contained in this document is subject to change without notice. If you find any
problems in the documentation, please report them to us in writing. Oracle Corporation does not
warrant that this document is error free. Except as may be expressly permitted in your license agreement
for these Programs, no part of these Programs may be reproduced or transmitted in any form or by any
means, electronic or mechanical, for any purpose, without the express written permission of Oracle
Corporation.
If the Programs are delivered to the U.S. Government or anyone licensing or using the Programs on
behalf of the U.S. Government, the following notice is applicable:
Restricted Rights Notice Programs delivered subject to the DOD FAR Supplement are "commercial
computer software" and use, duplication, and disclosure of the Programs including documentation, shall
be subject to the licensing restrictions set forth in the applicable Oracle license agreement. Otherwise,
Programs delivered subject to the Federal Acquisition Regulations are "restricted computer software"
and use, duplication, and disclosure of the Programs shall be subject to the restrictions in FAR 52.227-19,
Commercial Computer Software - Restricted Rights (June, 1987). Oracle Corporation, 500 Oracle
Parkway, Redwood City, CA 94065.
Oracle is a registered trademark, and Oracle Forms, SQL*Plus and PL/SQL are trademarks or registered
trademarks of Oracle Corporation. All other company or product names mentioned are used for
identification purposes only and may be trademarks of their respective owners.
Send Us Your Comments
SQL*Plus Quick Reference, Release 8.1.5
Part No. A66735-01
Oracle Corporation welcomes your comments and suggestions on the quality and usefulness of this
publication. Your input is an important part of the information used for revision.
■ Did you find any errors?
■ Is the information clearly presented?
■ Do you need more information? If so, where?
■ Are the examples correct? Do you need more examples?
■ What features did you like most about this manual?
If you find any errors or have any other suggestions for improvement, please indicate the chapter,
section, and page number (if available). You can send comments to us in the following ways:
■ Electronic mail: [email protected]
■ FAX: +61 3 9690 0043 Attention: SQL*Plus Documentation Manager
■ Postal service:
SQL*Plus Documentation Manager,
Australian Product Development Center,
Oracle Corporation Australia Pty Ltd,
324 St. Kilda Road,
Melbourne, VIC 3004,
Australia
If you would like a reply, please give your name, address, and telephone number below.
If you have problems with the software, please contact your local Oracle Support Services center.
iii
iv
SQL*Plus Quick Reference
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.
Other words are explained where used if their meaning is not explained by context.
Punctuation
Enter other punctuation marks (such as parentheses) where shown in the command
syntax.
STARTUP [FORCE][RESTRICT][PFILE=filename][MOUNT[OPEN[RECOVER]]
[database]][mount_options]|[NOMOUNT]
where mount_options requires the following syntax:
[EXCLUSIVE|[PARALLEL|SHARED][RETRY]]
SHUTDOWN [ABORT|IMMEDIATE|NORMAL|TRANSACTIONAL]
Shuts down a currently running Oracle instance, optionally closing and
dismounting a database.
{EXIT|QUIT} [SUCCESS|FAILURE|WARNING|n|variable|:BindVariable]
[COMMIT|ROLLBACK]
Commits all pending changes, terminates SQL*Plus, and returns control
to the operating system.
/ (slash)
Executes the SQL command or PL/SQL block currently stored in the
SQL buffer. Does not list the command.
EXEC[UTE] statement
Executes a single PL/SQL statement.
R[UN]
Lists and executes the SQL command or PL/SQL block currently stored
in the SQL buffer.
HELP [topic]
Accesses help on SQL*Plus commands.
Use the following command to execute host operating system commands.
HO[ST] [command]
Executes a host operating system command without leaving SQL*Plus.
Note: With some operating systems, you can use a "$" (VMS), "!"
(UNIX) or another character instead of HOST. See the Oracle
installation and user ’s manual(s) provided for your operating
system for details.
A[PPEND] text
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).
I[NPUT] [text]
Adds one or more new lines of text after the current line in the buffer.
@@ file_name[.ext]
Runs the specified nested command file.
ED[IT] [file_name[.ext]]
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.
REM[ARK]
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.
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.
PAU[SE] [text]
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.
PROMPT [text]
Sends the specified message or a blank line to the user’s screen.
Use the following symbols to create substitution variables and parameters for use in
command files.
&n
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.
&user_variable, &&user_variable
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.
. (period)
Terminates a substitution variable followed by a character that would
otherwise be part of the variable name.
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 FORMAT followed by the appropriate format element to specify
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:
SPO[OL] [filename[.ext]|OFF|OUT]
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.
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
username off Oracle, but does not exit SQL*Plus.
source table and determines which rows and columns COPY copies
from it.
PASSW[ORD] [username]
Allows you to change a password without echoing the password on an
input device.
Miscellaneous
ARCHIVE LOG {LIST|STOP}|{START|NEXT|ALL|integer} [TO destination]
Starts or stops automatic archiving on online redo log files, manually
(explicitly) archives specified redo log files, or displays information
about redo log files.
DESC[RIBE] [schema.]object[@net_service_name]
Lists the column definitions for the specified table, view or synonym or
the specifications for the specified function or procedure.
SHO[W] [option]
Lists the value of a SQL*Plus system variable. Use one of the following
terms or clauses in place of option:
system_variable
ALL
BTI[TLE]
DESCRIBE
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
Enter any system variable set by the SET command in place of system_
variable.
Notes