Datasheet
10
Chapter 1
Introducing SQL
Editing the SQL Buffer
The most recent SQL statement executed or entered is stored in the SQL buffer of SQL*Plus.
You can run the command in this buffer again by simply typing a slash or using the
RUN
command.
SQL*Plus provides a set of commands to edit the buffer. Suppose you want to add another
column or add an
ORDER BY condition to the statement in the buffer. You do not need to
type the entire SQL statement again. Instead, just edit the existing statement in the buffer.
One way to edit the SQL*Plus buffer is to use the
EDIT command to write the buffer
to an operating-system file named
afiedt.buf (this is the default filename, which can be
changed) and then use a system editor to make changes.
You can use your favorite text editor by defining it in SQL*Plus. For
example, to make Notepad your favorite editor, just issue the command
DEFINE _EDITOR = NOTEPAD. You need to provide the entire path if the
program is not available in the search path.
Another way to edit the buffer is to use the SQL*Plus editing commands. You can make
changes, delete lines, add text, and list the buffer contents using the commands described in
the following sections. Most editing commands operate on the current line. You can change
the current line simply by typing the line number. All commands can be abbreviated except
DEL (which is already abbreviated).
LIST
The LIST command lists the contents of the buffer. The asterisk indicates the current line.
The abbreviated command for
LIST is L.
SQL> L
1 SELECT empno, ename
2* FROM emp
SQL> LIST LAST
2* FROM emp
SQL>
The command LIST m n displays lines from m through n. If you substitute * for m or n, it
implies the current line. The command
LIST LAST displays the last line.
APPEND
The APPEND text command adds text to the end of line. The abbreviated command is A.
SQL> A WHERE empno <> 7926
2* FROM emp WHERE empno <> 7926
SQL>
95127c01.indd 10 2/18/09 6:37:07 AM