Linux中 oracle SQL*PLUS 命令大全
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                Linux中 oracle SQL*PLUS 命令大全
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                http://www.cnblogs.com/kerrycode/archive/2011/06/09/2076248.html
?
?
ORACLE SQL*PLUS 命令大全
2011-06-09 23:00 by 瀟湘隱者, 1324 visits, 收藏, 編輯
?其實網上已經有SQL*PLUS命令大全這方面的資料了,不過大都不完整,只覆蓋了一些常用的命令,本著學習、實踐的原則,也為了梳理、總結SQL*PLUS方面的知識,自己也整理了一份這方面的文檔資料,不足之處還請大家多多指教。
?
---1:?HELP?INDEXHELP?命令查詢相關命令的信息。
你可以從下面看到大概有54個SQL*PLUS命令。每個命令都有大量的參數選項,你不可能清楚的記得每個命令
以及它相關的參數細節,所以當你遺忘時,就可以用HELP命令來查看相關命令的命令信息
SQL>?HELP?INDEX
Enter?Help?[topic]?for?help.
?@?????????????COPY?????????PAUSE????????????????????SHUTDOWN
?@@????????????DEFINE???????PRINT????????????????????SPOOL
?/?????????????DEL??????????PROMPT???????????????????SQLPLUS
?ACCEPT????????DESCRIBE?????QUIT?????????????????????START
?APPEND????????DISCONNECT???RECOVER??????????????????STARTUP
?ARCHIVE?LOG???EDIT?????????REMARK???????????????????STORE
?ATTRIBUTE?????EXECUTE??????REPFOOTER????????????????TIMING
?BREAK?????????EXIT?????????REPHEADER????????????????TTITLE
?BTITLE????????GET??????????RESERVED?WORDS?(SQL)?????UNDEFINE
?CHANGE????????HELP?????????RESERVED?WORDS?(PL/SQL)??VARIABLE
?CLEAR?????????HOST?????????RUN??????????????????????WHENEVER?OSERROR
?COLUMN????????INPUT????????SAVE?????????????????????WHENEVER?SQLERROR
?COMPUTE???????LIST?????????SET
?CONNECT???????PASSWORD?????SHOW
?
?HELP?[TOPIC]?來查看相關命令介紹以及語法。?可以用?代替HELP
?
?例子:
?HELP?DESCRIBE
?
???COPY
?
---2:?@
?運行調入內存的sql文件(文件可以是本機腳本文件或web服務器上的腳本文件)
?@跟START命令具有相同功能。可以用START替代。可以不指定該文件擴展名
?
?
?@?("at"?sign)
?-------------
?Runs?the?SQL*Plus?statements?in?the?specified?script.?The?script?can?be
?called?from?the?local?file?system?or?a?web?server.?Only?the?url?form?is
?supported?in?iSQL*Plus.
?@?{url|file_name[.ext]}?[arg?...]
?where?url?supports?HTTP?and?FTP?protocols?in?the?form:
????http://host.domain/script.sql
例子:執行test。sql腳本文件
?
?SQL>?@?F:/test.sql
?
?其中test.sql中腳本如下所示
?
??PROMPT
??PROMPT?'顯示5條員工信息'
??PROMPT
??
??SELECT?*?FROM?SCOTT.EMP?WHERE?ROWNUM?<=?5
??/
??
??運行結果如圖所示。
?
?---3?@@
?@@?運行調入內存的sql文件,跟@命令很相像。如果運行的腳本文件中有嵌入腳本,則@@比較有用。
?
?@@?(double?"at"?sign)
?---------------------
?Runs?the?specified?script.?This?command?is?almost?identical?to
?the?@?command.?It?is?useful?for?running?nested?scripts?because?it
?has?the?additional?functionality?of?looking?for?the?nested?script
?in?the?same?url?or?path?as?the?calling?script.?Only?the?url?form
?is?supported?in?iSQL*Plus.
?@@?{url|file_name[.ext]}?[arg?...]
?
---4??/?
執行當前緩沖區的命令(運行上一次執行的SQL語句).
SQL>?HELP?/
?/?(slash)
?---------
?Executes?the?most?recently?executed?SQL?command?or?PL/SQL?block
?which?is?stored?in?the?SQL?buffer.?Use?slash?(/)?at?the?command
?prompt?or?line?number?prompt?in?SQL*Plus?command?line,?or?use
?slash?(/)?in?the?iSQL*Plus?Workspace.?The?buffer?has?no?command
?history?and?does?not?record?SQL*Plus?commands.
?
?
?例子:如下圖所示:
?
---5??ACCEPT
?SQL>?HELP??ACCEPT?
?ACCEPT可以修改既有變量,也可定義一個新變量并等待用戶輸入初始值。
?ACCEPT
?------
?Reads?a?line?of?input?and?stores?it?in?a?given?substitution?variable.
?In?iSQL*Plus,?displays?the?Input?Required?screen?for?you?to?enter?a
?value?for?the?substitution?variable.
?ACC[EPT]?variable?[NUM[BER]?|?CHAR?|?DATE?|?BINARY_FLOAT?|?BINARY_DOUBLE]
?[FOR[MAT]?format]?[DEF[AULT]?default]?[PROMPT?text?|?NOPR[OMPT]]?[HIDE] ---6?APPEND
?????將text附加到當前行之后。
SQL>?HELP?APPEND
?APPEND
?------
?Adds?text?to?the?end?of?the?current?line?in?the?SQL?buffer.
?A[PPEND]?text
?Not?available?in?iSQL*Plus
?
?
---7??ARCHIVE?LOG?
??????啟動或停止歸檔在線重做日志文件。
SQL>?HELP?ARCHIVE?LOG
?????
?ARCHIVE?LOG
?-----------
?Starts?or?stops?automatic?archiving?of?online?redo?log?files,
?manually?(explicitly)?archives?specified?redo?log?files,?or
?displays?information?about?redo?log?files.
?ARCHIVE?LOG?{LIST|STOP}?|?{START|NEXT|ALL|integer}?[TO?destination]
?
---8??ATTRIBUTE
SQL>?HELP?ATTRIBUTE
?ATTRIBUTE
?---------
?Specifies?display?characteristics?for?a?given?attribute?of?an?Object?Type
?column,?such?as?the?format?of?NUMBER?data.?Columns?and?attributes?should
?not?have?the?same?names?as?they?share?a?common?namespace.?Lists?the
?current?display?characteristics?for?a?single?attribute?or?all?attributes.
?ATTRIBUTE?[type_name.attribute_name?[option?...?]]
?where?option?represents?one?of?the?following?terms?or?clauses:
?????ALI[AS]?alias
?????CLE[AR]
?????FOR[MAT]?format
?????LIKE?{type_name.attribute_name?|?alias}
?????ON|OFF
---9??BREAK
?? ??break命令抑制重復的列或表達你的名字的默認值。因此,要制止重復在ORDER BY子句中指定的列值,使用最簡單的形式break命令:
SQL>?HELP??BREAK
?BREAK
?-----
?Specifies?where?changes?occur?in?a?report?and?the?formatting
?action?to?perform,?such?as:
?-?suppressing?display?of?duplicate?values?for?a?given?column
?-?skipping?a?line?each?time?a?given?column?value?changes
???(In?iSQL*Plus,?only?when?Preformatted?Output?is?ON)
?-?printing?computed?figures?each?time?a?given?column?value
???changes?or?at?the?end?of?the?report.
?Enter?BREAK?with?no?clauses?to?list?the?current?BREAK?definition.
?BRE[AK]?[ON?report_element?[action?[action]]]?...
?where?report_element?has?the?following?syntax:
?????{column?|?expression?|?ROW?|?REPORT}
?and?where?action?has?the?following?syntax:
?????[SKI[P]?n?|?[SKI[P]]?PAGE]?[NODUP[LICATES]?|?DUP[LICATES]]
?The?SKIP?option?is?not?supported?in?iSQL*Plus
---10??BTITLE
??設置格式化頁腳
??
SQL>?HELP??BTITLE?;
?BTITLE
?------
?Places?and?formats?a?specified?title?at?the?bottom?of?each?report
?page,?or?lists?the?current?BTITLE?definition.
?BTI[TLE]?[printspec?[text|variable]?...]?|?[OFF|ON]
?where?printspec?represents?one?or?more?of?the?following?clauses:
?????COL?n??????????LE[FT]????????BOLD
?????S[KIP]?[n]?????CE[NTER]??????FORMAT?text
?? ? TAB?n??????????R[IGHT]??
?? ?
復制代碼 ---11?CHANGE??????將SQL*Plus緩沖區當前行的old_value替換為new_value;
?Changes?the?first?occurrence?of?the?specified?text?on?the?current
?line?of?the?SQL?buffer.?The?buffer?has?no?command?history?list?and
?does?not?record?SQL*Plus?commands.
?C[HANGE]?sepchar?old?[sepchar?[new[sepchar]]]
?Not?available?in?iSQL*Plus
---12?CLEAR
??????清除或重設當前指定配置的值。CLEAR?BUFFER?即清空緩存區所有行。
Resets?or?erases?the?current?value?or?setting?for?the?specified?option.
CL[EAR]?option?...
where?option?represents?one?of?the?following?clauses:
????BRE[AKS]
????BUFF[ER]
????COL[UMNS]
????COMP[UTES]
????SCR[EEN]
????SQL
????TIMI[NG]
CLEAR?SCREEN?is?not?available?in?iSQL*Plus
例子:
???CLEAR?BUFFER;
??
???CLEAR?SQL;
---13??COLUMN
???????用于格式化列標題和列數據的現實格式。
?Specifies?display?attributes?for?a?given?column,?such?as:
?????-?text?for?the?column?heading
?????-?alignment?for?the?column?heading
?????-?format?for?NUMBER?data
?????-?wrapping?of?column?data
?Also?lists?the?current?display?attributes?for?a?single?column
?or?all?columns.
?COL[UMN]?[{column?|?expr}?[option?...]?]
?where?option?represents?one?of?the?following?clauses:
?????ALI[AS]?alias
?????CLE[AR]
?????ENTMAP?{ON|OFF}
?????FOLD_A[FTER]
?????FOLD_B[EFORE]
?????FOR[MAT]?format
?????HEA[DING]?text
?????JUS[TIFY]?{L[EFT]?|?C[ENTER]?|?R[IGHT]}
?????LIKE?{expr?|?alias}
?????NEWL[INE]
?????NEW_V[ALUE]?variable
?????NOPRI[NT]?|?PRI[NT]
?????NUL[L]?text
?????OLD_V[ALUE]?variable
?????ON|OFF
?????WRA[PPED]?|?WOR[D_WRAPPED]?|?TRU[NCATED]
?????
例子:
??????
?
---14?COMPUTE
In?combination?with?the?BREAK?command,?calculates?and?prints
summary?lines?using?various?standard?computations.?Also?lists
all?COMPUTE?definitions.
COMP[UTE]?[function?[LAB[EL]?text]?...
??OF?{expr|column|alias}?...
??ON?{expr|column|alias|REPORT|ROW}?...]
---15?CONNECT
??????連接數據數據庫命令.如果是SYSDBA或SYSOPER賬號,則必須在后面加上AS?{SYSOPER?|?SYSDBA},否則會報錯。
CONNECT
-------
Connects?a?given?username?to?the?Oracle?Database.?When?you?run?a
CONNECT?command,?the?site?profile,?glogin.sql,?and?the?user?profile,
login.sql,?are?processed?in?that?order.?CONNECT?does?not?reprompt
for?username?or?password?if?the?initial?connection?does?not?succeed.
CONN[ECT]?[{logon|/|proxy}?[AS?{SYSOPER|SYSDBA}]]
where?logon?has?the?following?syntax:
????username[/password][@connect_identifier]
例子:
SQL>CONNECT?SYSDBA/U*jd24))(&^??AS?SYSDBA;
?
SQL>CONN?SYSTEM/KERRY123456
已連接。
SQL>?HELP?CONN
?
?
---16?COPY
?? ??COPY可以完成遠程數據庫、本地數據庫或ORACLE數據庫與非ORACLE 數據庫之間的數據復制
Copies?data?from?a?query?to?a?table?in?the?same?or?another
database.?COPY?supports?CHAR,?DATE,?LONG,?NUMBER?and?VARCHAR2.
COPY?{FROM?database?|?TO?database?|?FROM?database?TO?database}
???????????{APPEND|CREATE|INSERT|REPLACE}?destination_table
???????????[(column,?column,?column,?...)]?USING?query
where?database?has?the?following?syntax:
????username[/password]@connect_identifier
????
---17???DEFINE
?定義替換變量并附值給它,或列出指定賦值變量值或所有變量
?Specifies?a?substitution?variable?and?assigns?a?CHAR?value?to?it,?or
?lists?the?value?and?variable?type?of?a?single?variable?or?all?variables.
?DEF[INE]?[variable]?|?[variable?=?text]
?
?例子:
SQL>?DEFINE
DEFINE?_DATE???????????=?"09-6月?-11"?(CHAR)
DEFINE?_CONNECT_IDENTIFIER?=?"orcl"?(CHAR)
DEFINE?_USER???????????=?"SYSTEM"?(CHAR)
DEFINE?_PRIVILEGE??????=?""?(CHAR)
DEFINE?_SQLPLUS_RELEASE?=?"1002000100"?(CHAR)
DEFINE?_EDITOR?????????=?"Notepad"?(CHAR)
DEFINE?_O_VERSION??????=?"Oracle?Database?10g?Enterprise?Edition?Release?10.2.0.1.0?-?
With?the?Partitioning,?OLAP?and?Data?Mining?options"?(CHAR)
DEFINE?_O_RELEASE??????=?"1002000100"?(CHAR)
DEFINE?_RC?????????????=?"1"?(CHAR)
SQL>?DEFINE?_EDITOR
DEFINE?_EDITOR?????????=?"Notepad"?(CHAR)
---18???DEL
???????DEL刪除命令緩沖區的某一行。?DEL?刪除當前行??DEL?n?刪除第n行。
?Deletes?one?or?more?lines?of?the?SQL?buffer.?The?buffer?has?no
?command?history?list?and?does?not?record?SQL*Plus?commands.
?DEL?[n?|?n?m?|?n?*?|?n?LAST?|?*?|?*?n?|?*?LAST?|?LAST]
?Not?available?in?iSQL*Plus
?
?例子:
?
?DEL?1;
---19???DESCRIBE
?返回數據庫所存儲對象的描述。這個命令大家用得相當多,比如查看表的數據字典等,在此不細說。
?Lists?the?column?definitions?for?a?table,?view,?or?synonym
?or?the?specifications?for?a?function?or?procedure.
?DESC[RIBE]?{[schema.]object[@connect_identifier]}
?
?
?例子:
?DESC?SCOTT.EMP;
?
SQL>??DESC?SCOTT.EMP;
?名稱??????????????????????????????????????是否為空??類型
?-----------------------------------------?--------?-----------------------
?EMPNO??????????????????????????????????????????????NOT?NULL?NUMBER(4)
?ENAME??????????????????????????????????????????????VARCHAR2(10)
?JOB????????????????????????????????????????????????VARCHAR2(9)
?MGR????????????????????????????????????????????????NUMBER(4)
?HIREDATE???????????????????????????????????????????DATE
?SAL????????????????????????????????????????????????NUMBER(7,2)
?COMM???????????????????????????????????????????????NUMBER(7,2)
?DEPTNO?????????????????????????????????????????????NUMBER(2)
---20??DISCONNECT
?讓當前用戶從ORACLE數據庫斷開,但是不退出?SQL*PLUS
?Commits?pending?changes?to?the?database?and?logs?the?current
?user?out?of?Oracle,?but?does?not?exit?SQL*Plus.
?In?SQL*Plus?command?line,?use?EXIT?or?QUIT?to?log?out?of?Oracle
?and?return?control?to?your?computer''s?operating?system.
?In?iSQL*Plus,?click?the?Logout?button?to?log?out?of?Oracle.
?DISC[ONNECT]
?
?例子
?SQL>?DISCONNECT;
?從?Oracle?Database?10g?Enterprise?Edition?Release?10.2.0.1.0?-?Production
?With?the?Partitioning,?OLAP?and?Data?Mining?options?斷開
?
?如果想退出SQL*PLUS程序,可以用EXIT或QUIT ---21??EDIT
?調用操作系統文本編輯器打開指定文件或編輯緩沖區的內容。如果不指定文件名,例如??EDIT?F:/,則會提示您創建新的文件。
?文本編輯器在Windows下是Notepad,?在Unix或Linux下是Vi或emacs,可以用DEFINE?_EDITOR?=?‘編輯器名字’改變默認編輯器
?
?Invokes?an?operating?system?text?editor?on?the?contents?of?the
?specified?file?or?on?the?contents?of?the?SQL?buffer.?The?buffer
?has?no?command?history?list?and?does?not?record?SQL*Plus?commands.
?ED[IT]?[file_name[.ext]]
?Not?available?in?iSQL*Plus
?
?例子:不指定文件名
?SQL>?EDIT?F:/
?
?會創建一個*。sql文件,如下圖所示
?SQL>?EDIT?F:/123.TXT?創建123.txt文件。如下圖所示?
?
---22??EXECUTE
??執行存儲過程或PL/SQL塊
?Executes?a?single?PL/SQL?statement?or?runs?a?stored?procedure.
?EXEC[UTE]?statement
---23??EXIT
?退出SQL*PLUS
?Commits?or?rolls?back?all?pending?changes,?logs?out?of?Oracle,
?terminates?SQL*Plus?and?returns?control?to?the?operating?system.
?In?iSQL*Plus,?commits?or?rolls?back?all?pending?changes,?stops
?processing?the?current?iSQL*Plus?script?and?returns?focus?to?the
?Workspace.?There?is?no?way?to?access?the?return?code?in?iSQL*Plus.
?In?iSQL*Plus?click?the?Logout?button?to?log?out?of?Oracle?Database.
?{EXIT|QUIT}?[SUCCESS|FAILURE|WARNING|n|variable|:BindVariable]
???[COMMIT|ROLLBACK]
?
---24???GET
????????將SQL文件的內容讀入SQL*Plus緩沖區。查看保存的腳本
?Loads?a?SQL?statement?or?PL/SQL?block?from?a?script?into?the?SQL?buffer.
?In?iSQL*Plus?click?the?Load?Script?button?to?load?a?script?into?the
?Workspace.?The?buffer?has?no?command?history?list?and?does?not?record
?SQL*Plus?commands.
?GET?[FILE]?file_name[.ext]?[LIST?|?NOLIST]
?Not?available?in?iSQL*Plus
例子:SQL>?GET?FILE?F:/11.EXT?LIST
??1??1111111
??2*?111111
??
??其中1,2所列內容是我放在11.EXT中的內容
?
?
?
---25?HOST
?HOST
?----
?Executes?an?operating?system?command?without?leaving?SQL*Plus.
?Enter?HOST?without?command?to?display?an?operating?system?prompt.
?You?can?then?enter?multiple?operating?system?commands.
?HO[ST]?[command]
?Not?available?in?iSQL*Plus
---26?INPUT
?INPUT
?-----
?Adds?one?or?more?new?lines?of?text?after?the?current?line?in?the
?SQL?buffer.?The?buffer?has?no?command?history?list?and?does?not
?record?SQL*Plus?commands.
?I[NPUT]?[text]
?Not?available?in?iSQL*Plus
---27?LIST
??????列出SQL*Plus緩存區的所有行或指定的N行語句。例如?LIST?N;
?LIST
?----
?Lists?one?or?more?lines?of?the?most?recently?executed?SQL?command
?or?PL/SQL?block?which?is?stored?in?the?SQL?buffer.?Enter?LIST?with
?no?clauses?to?list?all?lines.?In?SQL*Plus?command-line?you?can?also
?use?";"?to?list?all?the?lines?in?the?SQL?buffer.?The?buffer?has?no
?command?history?list?and?does?not?record?SQL*Plus?commands.
?L[IST]?[n?|?n?m?|?n??*?|?n?LAST?|?*?|?*?n?|?*?LAST?|?LAST]
?例子:
??????SQL>?LIST
??????1*?SELECT?*?FROM?SCOTT.EMP
---28?PASSWORD;
????更改數據庫用戶密碼,不指定用戶,則默認跟改SYS用戶賬號
?PASSWORD
?--------
?Allows?you?to?change?a?password?without?displaying?it?on?an?input?device.
?In?iSQL*Plus,?use?the?Password?screen?to?change?your?password.
?PASSW[ORD]?[username]
?Not?available?in?iSQL*Plus
?例子:
???????SQL>?PASSWORD?
更改?SYS?的口令
舊口令:?******
新口令:******
?
?
?
---29?PAUSE;
?PAUSE
?-----
?Displays?the?specified?text?then?waits?for?the?user?to?press?RETURN.
?In?iSQL*Plus,?displays?the?Next?Page?button?which?the?user?must?click
?to?continue.
?PAU[SE]?[text]
---30?PRINT;
??????顯示當前綁定變量值或列出所有綁定變量
?-----
?Displays?the?current?values?of?bind?variables,?or?lists?all?bind
?variables.
?PRI[NT]?[variable?...]
? 復制代碼 ---31?PROMPT;
??????使用PROMPT命令可以在屏幕上輸出一行數據。這種方式有助于在腳本文件中向用戶
??????傳遞相應信息。比如我一個腳本文件Test.sql里面有下面這一段腳本:
??????PROMPT
??????PROMPT?'顯示5條員工信息'
??????PROMPT
??????
??????SELECT?*?FROM?SCOTT.EMP?WHERE?ROWNUM?<?5;
??????
??????
??????
?PROMPT
?------
?Sends?the?specified?message?or?a?blank?line?to?the?users?screen.
?PRO[MPT]?[text]
?例子:
?SQL>?PROMPT?HELLO?KERRY
?HELLO?KERRY
?
?
---32?QUIT;
??????提交或回滾所有的變化,退出ORACLE,中斷SQL*PLUS。
?QUIT?(Identical?to?EXIT)
?----
?Commits?or?rolls?back?all?pending?changes,?logs?out?of?Oracle,
?terminates?SQL*Plus?and?returns?control?to?the?operating?system.
?In?iSQL*Plus,?commits?or?rolls?back?all?pending?changes,?stops
?processing?the?current?iSQL*Plus?script?and?returns?focus?to?the
?Workspace.?There?is?no?way?to?access?the?return?code?in?iSQL*Plus.
?In?iSQL*Plus?click?the?Logout?button?to?log?out?of?Oracle?Database.
?{QUIT|EXIT}?[SUCCESS|FAILURE|WARNING|n|variable|:BindVariable]
???[COMMIT|ROLLBACK]
---33?RECOVER;
?RECOVER
?-------
?Performs?media?recovery?on?one?or?more?tablespaces,?one?or?more
?datafiles,?or?the?entire?database.
?Because?of?possible?network?timeouts,?it?is?recommended?that?you
?use?SQL*Plus?command-line,?not?iSQL*Plus,?for?long?running?DBA
?operations?such?as?RECOVER.
?RECOVER?{general?|?managed}?|?BEGIN?BACKUP?|?END?BACKUP}
?
---34?REMARK
?REMARK
?------
?Begins?a?comment?in?a?script.?SQL*Plus?does?not?interpret?the?comment
?as?a?command.
?REM[ARK]
---35??REPFOOTER;
?REPFOOTER
?---------
?Places?and?formats?a?footer?at?the?bottom?of?a?report,?or?lists?the
?REPFOOTER?definition.
?REPF[OOTER]?[PAGE]?[printspec?[text|variable]?...]?|?[OFF|ON]
?where?printspec?represents?one?or?more?of?the?following?clauses:
?????COL?n??????????LE[FT]????????BOLD
?????S[KIP]?[n]?????CE[NTER]??????FORMAT?text
?????TAB?n??????????R[IGHT]
---36??REPFOOTER;
?REPFOOTER
?---------
?Places?and?formats?a?footer?at?the?bottom?of?a?report,?or?lists?the
?REPFOOTER?definition.
?REPF[OOTER]?[PAGE]?[printspec?[text|variable]?...]?|?[OFF|ON]
?where?printspec?represents?one?or?more?of?the?following?clauses:
?????COL?n??????????LE[FT]????????BOLD
?????S[KIP]?[n]?????CE[NTER]??????FORMAT?text
?????TAB?n??????????R[IGHT]
--37?HELP?RESERVED?WORDS?(SQL);
?????查看SQL中保留關鍵字。有時候在寫腳本時應該避免使用SQL保留關鍵字做變量、表名、字段名等
?????如果你不確認自己定義的變量是否是保留關鍵字,就可以用這個命令看看。如果你只想查看SQL的保留
?????關鍵字?可以用??HELP?RESERVED?WORDS?(SQL),如果想查看兩者就直接輸入HELP?RESERVED?WORDS?即可。
?
?RESERVED?WORDS?(SQL)
?-----------------------
?PL/SQL?Reserved?Words?have?special?meaning?in?PL/SQL,?and?may?not?be?used
?for?identifier?names?(unless?enclosed?in?"quotes").
?
?
?
---38?HELP?RESERVED?WORDS?(PL/SQL);
??????查看PL/SQL中保留關鍵字。類似上面命令。
?
?RESERVED?WORDS?(SQL)
--------------------
SQL?Reserved?Words?have?special?meaning?in?SQL,?and?may?not?be?used?for
identifier?names?unless?enclosed?in?"quotes".
An?asterisk?(*)?indicates?words?are?also?ANSI?Reserved?Words.
Oracle?prefixes?implicitly?generated?schema?object?and?subobject?names
with?"SYS_".?To?avoid?name?resolution?conflict,?Oracle?discourages?you
from?prefixing?your?schema?object?and?subobject?names?with?"SYS_".
?
?
---39?RUN
??????運行緩存區中保存的語句。
?RUN
?---
?Lists?and?executes?the?most?recently?executed?SQL?command?or
?PL/SQL?block?which?is?stored?in?the?SQL?buffer.?The?buffer?has
?no?command?history?list?and?does?not?record?SQL*Plus?commands.
?R[UN]
---40?SAVE;
??????將SQL*Plus緩沖區的內容保存到所指定的文件中。如果用戶沒有指定文件擴展名,則默認
??????擴展名為SQL,后面的CREATE表示如果文件不存在創建一個文件。REPLACE表示如果文件不
??????存在則創建,否則替換覆蓋文件中的內容。?APPEND把緩沖區的內容追加到文件末尾。
?SAVE
?----
?Saves?the?contents?of?the?SQL?buffer?in?a?script.?In?iSQL*Plus,?click
?the?Save?Script?button?to?save?the?Workspace?contents?to?a?script.?The
?buffer?has?no?command?history?list?and?does?not?record?SQL*Plus?commands.
?SAV[E]?[FILE]?file_name[.ext]?[CRE[ATE]?|?REP[LACE]?|?APP[END]]
?Not?available?in?iSQL*Plus
?例子:
???????SQL>?save?F:/ttt.sql? ---41?SET
?設置系統變量以及SQL*PLUS環境變量
?----------------------------------------SET?命令選項--------------------------------------
?---SET?TIME??{ON?|?OFF}?
?控制當前時間的顯示。取值為ON時,表示在每個命令提示符前顯示當前系統時間;取值為OFF時不顯示當前的系統時間。
?
?---SET?PAUSE?{OFF|?ON?|?TEXT}
??設置SQL*Plus輸出結果時是否滾動顯示。
?????????當取值為NO時表示輸出結果每一頁都暫停,用戶按回車鍵后繼續顯示;?按CTRL?+?C退出每一頁顯示。
?????????當取值為OFF時表示一次性全部輸出?
?????????當取值為字符串時,每次暫停都顯示該字符串
?????????
?????????
?????SET?PAUSE?ON;
?????SET?PAUSE?'按回車鍵繼續'
?????SELECT?*?FROM?EMP;
?????
?---SET?PAGESIZE?{14?|?N};
?設置每頁打印的行數,該值包括NEWPAGE?設置的空行數
??
??
?---SET?NEWPAGE?{1|?N?|?NONE}??
?設置每頁打印標題前的空行數,默認值為1
??
?---SET?LINESIZE
?設置每行打印字符數,默認每行打印80個字符。可以設置LINESIZE,以避免折疊顯示。
??
?---SET?NUMFORMAT
?
?格式掩碼
?
?字符??????????????示例??????????????????????說明
?9?????????????????999???????????????????????查詢結果中數字替換格式中的掩碼
?0?????????????????999.00????????????????????格式中的掩碼屏蔽掉查詢結果中的數字。
?$?????????????????$999??????????????????????在查詢結果中的數字添加美元前綴。
?S?????????????????S999??????????????????????為數字顯示符號類型,通常用于顯示查詢結果中的正負數字
?PR????????????????999PR?????????????????????在尖括號中顯示數字。
?D?OR?.????????????99D99.99??????????????????在字符D或字符小數點"."位置上放置小數點
?,?????????????????999,99????????????????????在字符","位置上放置逗號
?RN?OR?rn??????????RN????????????????????????根據字符的大小寫形式,以大寫或者小寫的形式顯示羅馬數字。
?
?
?---SET?TIMING?{?ON?|?OFF?}
?顯示SQL命令消耗的系統時間。
?
?
---42?SHOW
??????顯示SQL*Plus系統變量值或當前SQL*Plus的環境,
?SHOW
?----
?Shows?the?value?of?a?SQL*Plus?system?variable,?or?the?current
?SQL*Plus?environment.?SHOW?SGA?requires?a?DBA?privileged?login.
?SHO[W]?option
?
?例子:
?
?SQL>?SHOW?SGA;
Total?System?Global?Area??612368384?bytes
Fixed?Size??????????????????1250428?bytes
Variable?Size?????????????272632708?bytes
Database?Buffers??????????331350016?bytes
Redo?Buffers????????????????7135232?bytes
?????
?
---43?SHUTDOWN
???關閉數據庫實例,使用SHUTDOWN時有5個參數可以選擇。
?SHUTDOWN
?--------
?Shuts?down?a?currently?running?Oracle?Database?instance,?optionally
?closing?and?dismounting?a?database.
?SHUTDOWN?[ABORT|IMMEDIATE|NORMAL|TRANSACTIONAL?[LOCAL]]
?
?SHUTDOWN?ABORT???????????????強制關閉,可能會丟失部分數據。如果數據庫重啟實例并打開數據庫時,后臺進程SMON會執行恢復操作
?
?以終止方式關閉時,?ORACLE將執行以下操作
??1:阻止任何用戶建立新的連接。同時阻止當前連接的用戶開始新的事務。
??2:立即終止當前正在執行的SQL語句。
??3:任何未提交的事務均不被回退。
??4:立即斷開所有用戶的連接,關閉、卸載數據庫,并終止實例。
?
?SHUTDOWN?NORMAL??????????????正常關閉方式
?
?以正常方式關閉時,ORACLE將執行以下操作
??1:阻止任何用戶建立新的連接
??2:等待當前所有正在連接的用戶主動斷開連接,已經連接的用戶能夠繼續當前的操作
??3:一旦所有的用戶都斷開連接,即立即關閉、卸載數據庫,并終止實例。
??
?SHUTDOWN?IMMEDIATE???????????立即關閉方式
?以立即關閉方式時,ORACLE將執行以下操作
?1:阻止任何用戶建立新的連接。同時阻止當前連接的用戶開始任何新的事務。
?2:任何未提交的事務均被回退。
?3:ORACLE不再等待用戶主動斷開連接,而是直接關閉、卸載數據庫,并終止實例。
?
?SHUTDOWN?TRANSACTIONAL???????事務關閉方式介于正常關閉方式與立即關閉方式之間。它能夠在盡可能短的時間內
??????????????????????????????關閉數據庫,但是能夠保證當前所有活動事務都可以被提交。
?以事務關閉方式時,ORACLE將執行以下操作
?1:阻止任何用戶建立新的連接,同時阻止當前連接的用戶開始任何新的事務。
?2;等待所有未提交的活動事務提交完畢,然后立即斷開用戶連接。
?3:關閉、卸載數據庫,并終止實例。???????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?
?---44?SPOOL;
???????將SQL*Plus中輸出的結果復制到filename所指定的文件中。
???????
?SPOOL
?-----
?Stores?query?results?in?a?file,?or?optionally?sends?the?file?to?a?printer.
?In?iSQL*Plus,?use?the?Preferences?screen?to?direct?output?to?a?file.
?SPO[OL]?[file_name[.ext]?[CRE[ATE]?|?REP[LACE]?|?APP[END]]?|?OFF?|?OUT]
?Not?available?in?iSQL*Plus
?
?例子:
?SQL>?SPOOL?F:/TEMP.TEXT;
?SQL>?SELECT?*?FROM?SCOTT.EMP;
?SQL>?SPOOL?OFF;
?
?---45??SQLPLUS
????????運行SQL*Plus
?SQLPLUS
?-------
?Starts?SQL*Plus?from?the?operating?system?prompt.
?SQLPLUS?[?[option]?[logon]?[start]?]
?where?option?has?the?following?syntax:
?????-H[ELP]
?????|?-V[ERSION]
?????|?[[-C[OMPATIBILITY]?x.y[.z]]?[-L[OGON]]
????????[-M[ARKUP]?markup_option]?[-R[ESTRICT]?{1|2|3}]?[-S[ILENT]]]
?and?where?markup_option?has?the?following?syntax:
?????HTML?[ON|OFF]?[HEAD?text]?[BODY?text]?[TABLE?text]
??????????[ENTMAP?{ON|OFF}]?[SPOOL?{ON|OFF}]?[PRE[FORMAT]?{ON|OFF}]
?and?where?logon?has?the?following?syntax:
?????{username[/password][@connect_identifier]?|?/}
?????[AS?{SYSOPER|SYSDBA}]?|?/NOLOG
?and?where?start?has?the?following?syntax:
?????@{url|filename[.ext]}?[arg?...]
?????
---46??START
???????將filename文件的內容讀入SQL*Plus緩沖區,然后執行緩沖區的腳本(運行腳本文件)
?START
?-----
?Runs?the?SQL*Plus?statements?in?the?specified?script.?The?script?can?be
?called?from?the?local?file?system?or?a?web?server.?Only?the?url?form?is
?supported?in?iSQL*Plus.
?STA[RT]?{url|file_name[.ext]}?[arg?...]
?where?url?supports?HTTP?and?FTP?protocols?in?the?form:
????http://host.domain/script.sql
---47?STARTUP
??????啟動ORACLE實例。
?STARTUP
-------
Starts?an?Oracle?instance?with?several?options,?including?mounting,
and?opening?a?database.
STARTUP?options?|?upgrade_options
where?options?has?the?following?syntax:
???[FORCE]?[RESTRICT]?[PFILE=filename]?[QUIET]?[?MOUNT?[dbname]?|
???[?OPEN?[open_options]?[dbname]?]?|
???NOMOUNT?]
where?open_options?has?the?following?syntax:
???READ?{ONLY?|?WRITE?[RECOVER]}?|?RECOVER
and?where?upgrade_options?has?the?following?syntax:
???[PFILE=filename]?{UPGRADE?|?DOWNGRADE}?[QUIET]
---?48?STORE
?STORE
?-----
?Saves?attributes?of?the?current?SQL*Plus?environment?in?a?script.
?STORE?{SET}?file_name[.ext]?[CRE[ATE]?|?REP[LACE]?|?APP[END]]
?Not?available?in?iSQL*Plus
?
---?49?TIMING
?TIMING
?------
?Records?timing?data?for?an?elapsed?time?period,?lists?the?current
?timer''s?name?and?timing?data,?or?lists?the?number?of?active?timers.
?TIMI[NG]?[START?text|SHOW|STOP]
---50??TTITLE;
???設置頁眉選項。
?TTITLE
?------
?Places?and?formats?a?title?at?the?top?of?each?report?page.
?Enter?TTITLE?with?no?clause?to?list?its?current?definition.
?The?old?form?of?TTITLE?is?used?if?only?a?single?word?or
?a?string?in?quotes?follows?the?TTITLE?command.
?TTI[TLE]?[printspec?[text|variable]?...]?|?[OFF|ON]
?where?printspec?represents?one?or?more?of?the?following?clauses:
?????COL?n??????????LE[FT]????????BOLD
?????S[KIP]?[n]?????CE[NTER]??????FORMAT?text
?????TAB?n??????????R[IGHT]
?????
?例子:
??????TTITLE?ON?????開啟頁眉
??????TTITLE?OFF????關閉頁眉
??????
??????SQL>?TTITLE?CENTER?'職工信息表'
??????SQL>?SELECT?*?FROM?SCOTT.EMP; 復制代碼
?
---51?UNDEFINE;????刪除一個或多個你定義的替換變量。
?UNDEFINE
?--------
?Deletes?one?or?more?substitution?variables?that?you?defined?either
?explicitly?(with?the?DEFINE?command),?or?implicitly?(with?a?START
?command?argument).
?UNDEF[INE]?variable?...
---52?VARIABLE;
?VARIABLE
?--------
?Declares?a?bind?variable?that?can?be?referenced?in?PL/SQL,?or
?lists?the?current?display?characteristics?for?a?single?variable
?or?all?variables.
VAR[IABLE]?[variable?[type]]
?where?type?represents?one?of?the?following:
?????NUMBER?????????CHAR??????????CHAR?(n?[CHAR|BYTE])
?????NCHAR??????????NCHAR?(n)?????VARCHAR2?(n?[CHAR|BYTE])
?????NVARCHAR2?(n)??CLOB??????????NCLOB
?????REFCURSOR??????BINARY_FLOAT??BINARY_DOUBLE
?????
---53?SQL>?WHENEVER?OSERROR
?WHENEVER?OSERROR
?----------------
?Performs?the?specified?action?(exits?SQL*Plus?by?default)?if?an
?operating?system?error?occurs?(such?as?a?file?writing?error).
?In?iSQL*Plus,?performs?the?specified?action?(stops?the?current
?script?by?default)?and?returns?focus?to?the?Workspace?if?an
?operating?system?error?occurs.
?WHENEVER?OSERROR?{EXIT?[SUCCESS|FAILURE|n|variable|:BindVariable]
???????????????????[COMMIT|ROLLBACK]?|?CONTINUE?[COMMIT|ROLLBACK|NONE]}
???????????????????
---54?
?WHENEVER?SQLERROR
?-----------------
?Performs?the?specified?action?(exits?SQL*Plus?by?default)?if?a
?SQL?command?or?PL/SQL?block?generates?an?error.
?In?iSQL*Plus,?performs?the?specified?action?(stops?the?current
?script?by?default)?and?returns?focus?to?the?Workspace?if?a?SQL
?command?or?PL/SQL?block?generates?an?error.
?WHENEVER?SQLERROR?{EXIT?[SUCCESS|FAILURE|WARNING|n|variable|:BindVariable]
????????????????????[COMMIT|ROLLBACK]?|?CONTINUE?[COMMIT|ROLLBACK|NONE]} 復制代碼
?
總結
以上是生活随笔為你收集整理的Linux中 oracle SQL*PLUS 命令大全的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 通过hibernate去调用存储过程
- 下一篇: 金融衍生产品
