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”
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:

SQL> SHOW HIST
history is ON and set to “100”

You can delete all history by running “hist clear”:

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:

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.

SQL> set history 1000

SQL> show history
History is ON and set to “1000”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.