RelationalDBDesign RelationalDBDesign

SQL* Plus CLI  «Prev  Next»
Lesson 15Line editing
ObjectiveUse SQL*Plus line-editing commands.

SQL Plus Line Editing Commands(How to use?)

SQL*Plus provides a set of line-editing commands to use in editing SQL statements. While these line-editing commands are crude by today's standards, they do allow you to correct minor mistakes without having to retype the entire SQL statement. There are just a few commands to learn, and they can save you a lot of time.

The SQL Buffer

Whenever you enter and execute a SQL statement, SQL*Plus holds that statement in an area of memory known as the SQL buffer. As long as the statement remains in the buffer, you can make changes to it, execute it, and make changes again. The line-editing commands all operate on the current statement in the buffer. This line-editing illustrates their use:
SQL buffer: A memory area used by SQL*Plus to hold the most recently entered SQL statement or PL/SQL block.

  1. Use the LIST command, abbreviated to L, to list lines in the buffer.
  2. The CHANGE, abbreviated to C, command may be used to change test on line, or to delete text.
  3. Use the DEL command, which may not be abbreviated, to delete one line or a range of lines.
  4. Use the INSERT command, abbreviated to I, to insert lines into the buffer.
  5. Use the APPEND command, abbreviated to A, to append text onto the end of a line.
  6. Use the forward-slash command to execute the SQL statement currently in the buffer.

Oracle Line Editing Commands
SQL statements remain in the buffer only until you execute another SQL statement. If you have a 100-line statement in the buffer and you inadvertently type COMMIT, the 100-line statement will be replaced by the word COMMIT. If you are editing long statements, make sure to copy them to a text file before you begin.

Sql Plus Line Editing - Quiz

Here is a short quiz to test your knowledge of the line-editing commands.
SQL Plus Line Editing - Quiz