在sql*plus裡編輯SQL命令

zhyuh發表於2006-02-20

常用的編輯命令,包括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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章