首页 > 数据库 > 数据库开发技术 > 在sql*plus里编辑SQL命令
常用的编辑命令,包括append, change, input, del, list, clear buffer等
[@more@]SQL> select owner,object_nam
2 from dba_objects;
select owner,object_nam
*
ERROR at line 1:
ORA-00904: "OBJECT_NAM": invalid identifier
1. 将object_name改成object_name,用change (C)
SQL> c/nam/name
1* select owner,object_name
查看修改后结果,用list
SQL> list
1 select owner,object_name
2* from dba_objects
SQL> /
2. 在结果集中增加一列object_id,用append (A)
--先列出buffer中第一行sql
SQL> list 1
1* select owner,object_name
--在结果中增加一列
SQL> a ,object_id
1* select owner,object_name,object_id
--查看修改后的sql
SQL> list
1 select owner,object_name,object_id
2* from dba_objects
3. 往sql中追加2行,用input (I)
SQL> input
3 where owner='SYSTEM'
4 and rownum<6
5 /
--查看修改后的sql
SQL> list
1 select owner,object_name,object_id
2 from dba_objects
3 where owner='SYSTEM'
4* and rownum<6
4. 删除最后一行,用del last
SQL> del last
SQL> list
1 select owner,object_name,object_id
2 from dba_objects
3* where owner='SYSTEM'
5. 清除buffer里暂存的内容,用clear buffer (cl buff)
SQL> clear buffer
buffer cleared
--查看buffer里的内容d
SQL> list
SP2-0223: No lines in SQL buffer.
所有sql script编辑命令参考:
| Command | Abbreviation | Purpose |
|---|---|---|
| APPEND text | A text | adds text at the end of a line |
| CHANGE /old/new | C /old/new | changes old to new in a line |
| CHANGE /text | C /text | deletes text from a line |
| CLEAR BUFFER | CL BUFF | deletes all lines |
| DEL | (none) | deletes the current line |
| DEL n | (none) | deletes line n |
| DEL * | (none) | deletes the current line |
| DEL n * | (none) | deletes line n through the current line |
| DEL LAST | (none) | deletes the last line |
| DEL m n | (none) | deletes a range of lines (m to n) |
| DEL * n | (none) | deletes the current line through line n |
| INPUT | I | adds one or more lines |
| INPUT text | I text | adds a line consisting of text |
| LIST | L | lists all lines in the SQL buffer |
| LIST n | L n or n | lists line n |
| LIST * | L * | lists the current line |
| LIST n * | L n * | lists line n through the current line |
| LIST LAST | L LAST | lists the last line |
| LIST m n | L m n | lists a range of lines (m to n) |
| LIST * n | L * n | lists the current line through line n |
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/207/viewspace-815983/ ,如需转载,请注明出处,否则将追究法律责任。