Last time we introduced:SQL/PLUS Study NotesThis section describes the SQL/PLUS learning notes.Edit the current line command in the bufferNext, let's take a look at this part.
(1). change (enable you to change the current line)
First, use the list command to change the current line (or directly enter the row number, and press enter to change the current line ):
SQL> l -- display the buffer content:
- Select * from t1
- Where id> 1
- * And id <2 -- * indicates the default current row.
- SQL> l 2 -- list 2 changes the current row to the second row, but this does not affect the current row of the list (note)
- 2 * where id> 1
- SQL> l
- 1 select *
- 2 from t1
- 3 where
- 4 id <90 -- change 90 in the fourth row to 85
- 5 * and id> 80
- SQL> l 4 -- first change the current row to the fourth row
- 4 * id <90
- SQL> c/90/85 -- change command usage
- 4 * id <100
SQL> l -- use the list command to show that 90 has changed to 85. This is the new SQL statement that can be run using slash or run.
- 1 select *
- 2 from t1
- 3 where
- 4 id<85
- 5* and id>80
- SQL> run
- 1 select *
- 2 from t1
- 3 where
- 4 id<85
- 5* and id>80
- ID NAME
- ---------- ------
- 81 Testing
- 82 Testing
- 83 Testing
- 84 Testing
-
(2). append (append)
First, use the list command to change the current line (or directly enter the row number, and press enter to change the current line ):
- 1 select id, name
- 2 from t1
- 3 where
- 4 id <85 -- add and name = 'oracle 'later'
- 5 * and id> 80
- SQL> 4 -- change the current row
- 4 * id <85
- SQL> a and name = 'oracle '-- note that there are two spaces between a and. If there is only one space
- 4 * id <85 and name = 'oracle '-- 85 and will be together
- SQL> l -- list: text appended
- 1 select id, name
- 2 from t1
- 3 where
- 4 id <85 and name = 'oracle'
- 5 * and id> 80
- SQL>/
- ID NAME
- ------------------------------
- 83 Oracle
-
(3). input command
Insert a new line (to insert a new line after the current line)
First, use the list command to change the current line (or directly enter the row number, and press enter to change the current line)
Locate the new line you want to insert, And then I + will insert the text:
Example:
(This is Special) add a comment before the first line/* this is a testing demo! */
- SQL> 0/* this is a testing demo! */-- Add the comment before the first line.
- SQL> l
- 1 select id, name
- 2 from t1
- 3 where
- 4 id <85 -- Insert a new row under the fourth row
- 5 * and id> 80
- SQL> 4 -- first change the fourth row of the current behavior
- 4 * id <85
- SQL> I -- this is a demo! -- Input + text (text to be inserted)
- SQL> l
- 1 select id, name
- 2 from t1
- 3 where
- 4 id <85
- 5 -- this is a demo!
- 6 * and id> 80
- SQL>/
- ID NAME
- ------------------------------
- 81 Testing
- 82 Testing
- 83 Oracle
- 84 Testing
- SQL> 5 -- change the current row to 5, add a row after it, and add the new query condition and name = 'oracle'
- 5 * -- this is a demo!
- SQL> I and name = 'oracle '-- insert
- SQL> l
- 1 select id, name
- 2 from t1
- 3 where
- 4 id <85
- 5 -- this is a demo!
- 6 and name = 'oracle'
- 7 * and id> 80
- SQL>/
- ID NAME
- ------------------------------
- 83 Oracle
(4). del Delete line command
A. del n -- Delete row n
B. del n m -- delete rows from n to m
C. del n * -- Delete row n to the current row
D. del n last -- delete the nth row to the last row
This article describes how to edit the current line commands in the buffer zone in SQL/PLUS learning notes. I hope this introduction will help you.