SQL/PLUS learning notes: editing the current line of commands in the buffer

Source: Internet
Author: User

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:

 
 
  1. Select * from t1
  2. Where id> 1
  3. * And id <2 -- * indicates the default current row.
 
 
  1. 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. 2 * where id> 1
  3. SQL> l
  4. 1 select *
  5. 2 from t1
  6. 3 where
  7. 4 id <90 -- change 90 in the fourth row to 85
  8. 5 * and id> 80
  9. SQL> l 4 -- first change the current row to the fourth row
  10. 4 * id <90
  11. SQL> c/90/85 -- change command usage
  12. 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. 1  select *  
  2. 2  from t1  
  3. 3  where  
  4. 4  id<85 
  5. 5* and id>80  
  6. SQL> run  
  7. 1  select *  
  8. 2  from t1  
  9. 3  where  
  10. 4  id<85 
  11. 5* and id>80  
  12. ID NAME  
  13. ---------- ------  
  14. 81 Testing  
  15. 82 Testing  
  16. 83 Testing  
  17. 84 Testing  
  18.  

(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. 1 select id, name
  2. 2 from t1
  3. 3 where
  4. 4 id <85 -- add and name = 'oracle 'later'
  5. 5 * and id> 80
  6. SQL> 4 -- change the current row
  7. 4 * id <85
  8. SQL> a and name = 'oracle '-- note that there are two spaces between a and. If there is only one space
  9. 4 * id <85 and name = 'oracle '-- 85 and will be together
  10. SQL> l -- list: text appended
  11. 1 select id, name
  12. 2 from t1
  13. 3 where
  14. 4 id <85 and name = 'oracle'
  15. 5 * and id> 80
  16. SQL>/
  17. ID NAME
  18. ------------------------------
  19. 83 Oracle
  20.  

(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! */

 
 
  1. SQL> 0/* this is a testing demo! */-- Add the comment before the first line.
  2. SQL> l
  3. 1 select id, name
  4. 2 from t1
  5. 3 where
  6. 4 id <85 -- Insert a new row under the fourth row
  7. 5 * and id> 80
  8. SQL> 4 -- first change the fourth row of the current behavior
  9. 4 * id <85
  10. SQL> I -- this is a demo! -- Input + text (text to be inserted)
  11. SQL> l
  12. 1 select id, name
  13. 2 from t1
  14. 3 where
  15. 4 id <85
  16. 5 -- this is a demo!
  17. 6 * and id> 80
  18. SQL>/
  19. ID NAME
  20. ------------------------------
  21. 81 Testing
  22. 82 Testing
  23. 83 Oracle
  24. 84 Testing
  25. SQL> 5 -- change the current row to 5, add a row after it, and add the new query condition and name = 'oracle'
  26. 5 * -- this is a demo!
  27. SQL> I and name = 'oracle '-- insert
  28. SQL> l
  29. 1 select id, name
  30. 2 from t1
  31. 3 where
  32. 4 id <85
  33. 5 -- this is a demo!
  34. 6 and name = 'oracle'
  35. 7 * and id> 80
  36. SQL>/
  37. ID NAME
  38. ------------------------------
  39. 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.