1. 程式人生 > >Oracle 12C 新特性之 sqlplus查看History命令

Oracle 12C 新特性之 sqlplus查看History命令

let date 添加 version sys com delete 自動 ber

12c裏,Oracle推出了 History 命令,這很像 Shell 中的 history ,減少了重敲 SQL ,帶來了很多便利。

1. 查看history幫助
SQL> help history
HISTORY
-------
Stores, lists, executes, edits of the commands
entered during the current SQL*Plus session.
HIST[ORY] [N {RUN | EDIT | DEL[ETE]}] | [CLEAR]
N is the entry number listed in the history list.

Use this number to recall, edit or delete the command.
Example:
HIST 3 RUN - will run the 3rd entry from the list.
HIST[ORY] without any option will list all entries in the list.
2. hist 語法
HIST[ORY] [N {RUN | EDIT | DEL[ETE]}] | [CLEAR]
3. hist 默認是關閉的,在每次會話斷開連接後會自動關閉,當hist關閉後,hist 列表會被清空。
SQL> history;
SP2-1650: History is off, use "SET HIST[ORY] ON" to enable History.
4. 打開或者關閉hist
SQL> set hist on;
SQL> set hist off;
5.查看hist狀態
SQL> show hist;
history is OFF
6.設置hist保留的記錄數 ,默認保留記錄數是 100
SQL>set history 3;
7. 查看hist保留的記錄
SQL> hist list;
1 show con_name
2 show parameter version;
3 show hist;
說明:保留的記錄數 是按命令計算 而不是行數。
8. 運行指定記錄
SQL> hist;
1 select sysdate from dual;
2 show con_name
3 select date from dual;
SQL> hist 2 run;
CON_NAME
------------------------------
CDB$ROOT
9. 編輯之前的命令
hist 1 edit;
說明:可以像linux vi一樣操作,編輯保留後的記錄添加到記錄數末尾。
10. 刪除指定記錄數
hist 2 del
11.清空所有記錄數
SQL> hist clear;

Oracle 12C 新特性之 sqlplus查看History命令