In Oracle 12.2, SQL*Plus can keep the history of the commands executed. You can enable or disable the HISTORY command in the current SQL*Plus session by using the SET HISTORY command.
The history feature is not enabled by default, so after you start SQL*Plus, you need to enable history by running “set hist[ory] on”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
SQL> set history on SQL> select name from v$database; NAME ——— Test SQL> select host_name from v$instance; HOST_NAME —————————————————————- checking.compute-technologia.oraclecloud.internal SQL> history 1 select name from v$database; 2 select host_name from v$instance; SQL> exit |
You can run “show hist” to be sure that the history is enabled:
1 2 |
SQL> SHOW HIST history is ON and set to “100” |
You can delete all history by running “hist clear”:
1 2 3 |
SQL> HIST CLEAR SQL> HIST SP2-1651: History list is empty. |
The following example shows you how to enable or disable command history, and how to check the command history status:
1 2 3 4 5 6 7 8 9 |
SQL> set history on SQL> show history History is ON and set to “100” SQL> set history off SQL> show history History is OFF |
— To keep history of 1000 sql command.
1 2 3 4 |
SQL> set history 1000 SQL> show history History is ON and set to “1000” |