Oracle 12C R2-新特性-SQLPLUS提供檢視歷史命令的功能

lhrbest發表於2017-02-19

Oracle 12C R2-新特性-SQLPLUS提供檢視歷史命令的功能

型別:原創 分類:Oracle 12c 2017-02-18 10:03 閱讀(37)次 評論(0)

版權宣告:本文為博主原創文章,未經博主允許不得轉載。

Oracle 12C R2-新特性-SQLPLUS提供檢視歷史命令的功能

使使用者能夠從當前會話的歷史記錄列表中執行,編輯或刪除先前使用的SQL * PlusSQLPL / SQL命令。 可以使用SET HISTORY命令在當前SQL * Plus會話中啟用或禁用HISTORY命令。

官方文件:


http://docs.oracle.com/database/122/SQPUG/HISTORY.htm#SQPUG-GUID-CCF9B047-3122-4644-BA06-5FA4B5812E9F


 命令及功能

命令:HISTORY

功能:提供執行,編輯,刪除之前命令的功能。


 使用方法

預設HISTORY是沒有開啟的。



SQL> HIST 3 EDIT

SP2-1650: History is off, use "SET HIST[ORY] ON" to enable History.


2.1   開啟HISTORY

注意:預設記錄100條命令而不是命令列數。



SQL> set history on


2.2   檢視狀態


SQL> show hist;

history is ON and set to "2"


2.3   設定記錄命令條數


SQL> set history 2;  --設定為2條記錄


2.4   檢視已記錄的命令


SQL> hist

  1  show user

  2  select

     1

     from dual;


2.5   編輯之前的命令

SQL> hist

  1  select

     1

     from dual;

  2  show sga;

SQL> hist 1 edit

SQL> hist

  1  show sga;

  2  select

     sysdate

     from dual;


2.6   刪除之前的命令



SQL> hist

  1  show sga;

  2  select

     sysdate

     from dual;

SQL> hist 2 del[ete]

SQL> hist

  1  show sga;


2.7   執行之前的命令


SQL> hist

  1  select

     1

     from dual;

  2  show sga;

SQL> hist 2 run

 

Total System Global Area 1308622848 bytes

Fixed Size	    8792440 bytes

Variable Size	  889194120 bytes

Database Buffers	  402653184 bytes

Redo Buffers	    7983104 bytes


標籤:SQLPLUS 歷史命令

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-2133816/,如需轉載,請註明出處,否則將追究法律責任。

相關文章