Subscribe YouTube Channel For More Live Tutorials

12.2 New Feature: SQL*Plus History

12.2 New Feature: SQL*Plus History

Oracle 12.2 is finally released on premise and for that reason I would like to share some of my experiences with testing the new Features. First I would like to write about a small new feature, which would be very useful for all DBAs. Now SQL*Plus can keep history of the commands executed, and let you see and run these commands from the history.

SQL*Plus History is not enabled by default you need to enable history by running „set hist[ory] on“.

SQL> set hist on

To check history is enabled by running „hist[ory]“

SQL> show history
history is ON and set to "100"

The Default length of the history is 100. To Change the length of the history type „set hist 50“. The command will enable history and keep only the last 50 entries.

To see what is currently in your history type „hist[ory]“

SQL>history
   show history
  select host_name from v$instance;
  select file_name,bytes/1048576 from v$datafile;
  select name,bytes/1048576 from v$datafile;
  set lines 500
  select tablespace_name from dba_tablespaces;

To run a command from the history use the history run command

SQL> hist 3 run