Datasheet
8
Chapter 1
Introducing SQL
execute at this prompt. With SQL*Plus, you can enter, edit, and execute SQL statements;
perform database administration; and execute statements interactively by accepting user
input. You can also format query results and perform calculations.
sqlplus -help displays a help screen to show the various options avail-
able with starting SQL*Plus.
To exit from SQL*Plus, use the EXIT command. On platforms where a return code is
used, you can provide a return code while exiting. You can also use the
QUIT command to
complete the session.
EXIT and QUIT are synonymous.
Entering SQL Statements
A SQL statement can spread across multiple lines, and the commands are case insensitive.
The previously executed SQL statement will always be available in the SQL buffer. The
buffer can be edited or saved to a file. You can terminate a SQL statement in any of the fol-
lowing ways:
End with a semicolon (
;): The statement is completed and executed.
Enter a slash (
/) on a new line by itself: The statement in the buffer is executed.
Enter a blank line: The statement is saved in the buffer.
You can use the RUN command instead of a slash to execute a statement in the buffer.
The SQL prompt returns when the statement has completed execution. You can enter your
next command at the prompt.
Only SQL statements and PL/SQL blocks are stored in the SQL buffer;
SQL*Plus commands are not stored in the buffer.
Entering SQL*Plus Commands
SQL*Plus has its own commands to perform-specific tasks on the database, as well as to
format the query results. Unlike SQL statements, which are terminated with a semicolon or
a blank line, SQL*Plus commands are entered on a single line. Pressing Enter executes the
SQL*Plus command.
If you want to continue a SQL*Plus command onto the next line, you must end the cur-
rent line with a hyphen (
-), which indicates command continuation. This is in contrast to
SQL statements, which can be continued to the next line without a continuation opera-
tor. For example, the following SQL statement gives an error, because SQL*Plus treats the
hyphen operator (
-) as a continuation character:
SQL> SELECT 800 -
> 400 FROM dual;
95127c01.indd 8 2/18/09 6:37:06 AM