在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编辑命令参考:

CommandAbbreviationPurpose
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博客 ” ,链接:http://blog.itpub.net/207/viewspace-815983/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/207/viewspace-815983/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值