Datasheet

12
Chapter 1
Introducing SQL
SQL> L
1 SELECT empno, ename
2* FROM emp WHERE empno =
SQL>
CLEAR BUFFER
The CLEAR BUFFER command (abbreviated CL BUFF) clears the buffer. This deletes all lines
from the buffer.
SQL> L
1 SELECT empno, ename
2* FROM emp WHERE empno =
SQL> CL BUFF
buffer cleared
SQL> L
No lines in SQL buffer.
SQL>
Using Script Files
SQL*Plus provides commands to save the SQL buffer to a file, as well as to run SQL state-
ments from a file. SQL statements saved in a file are called a script file.
You can work with script files as follows:
To save the SQL buffer to an operating-system file, use the command
SAVE file na me. If
you do not provide an extension, the saved file will have an extension of
.sql.
By default, the
SAVE command will not overwrite an existing file. If you want to over-
write an existing file, you need to use the keyword
REPLACE.
To add the buffer to the end of an existing file, use the
SAVE file na m e APPEND
command.
You can edit the saved file using the
EDIT file na m e command.
You can bring the contents of a
script file to the SQL buffer using the GET file na m e
command.
If you want to run a script file, use the command
START file na m e. You can also run a
script file using
@file na m e.
An
@@file na m e used inside a script file looks for the filename in the directory where the
parent script file is saved and executes it.
Exercise 1.1 will familiarize you with the script file commands, as well as the other topics
I have covered so far.
95127c01.indd 12 2/18/09 6:37:07 AM