The SQL Buffer

SQL*Plus keeps a copy of the most recently entered SQL statement or PL/SQL block in an internal memory area known as the SQL buffer, often referred to simply as the buffer. The reason for this is simple. SQL*Plus needs a place to store your statement or block until you are finished entering it. SQL*Plus also provides you with the ability to edit the statement in the buffer. This can be a real convenience if you make a mistake halfway through typing a long, multiline query.

Tip

SQL*Plus buffers SQL statements and PL/SQL blocks, but not SQL*Plus commands. For example, the DESCRIBE command would not be buffered, but a SELECT statement would be. To help make the distinction, it may help to think in terms of where the command is executed. If you enter something to be executed by the database server, then it is buffered. If it’s a command local to SQL*Plus, then it is not buffered.

SQL*Plus provides two ways to edit the statement currently in the buffer. The first method is to use the set of line-editing commands built into SQL*Plus. The second method is to use the EDIT command to invoke an operating system-specific text editor, such as Notepad in the Windows environment, or vi under Unix.

Tip

If you are editing a statement in the buffer, be sure you don’t forget yourself and execute any other SQL command. Even a simple SQL command like COMMIT will overwrite the buffer. Commands to SQL*Plus, such as the editing commands, do not affect the buffer.

There are some other useful ...

Get Oracle SQL*Plus: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.