12.2 New Feature: SQL*Plus History


122_banner

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
2  show history
3  select host_name from v$instance;
4  select file_name,bytes/1048576 from v$datafile;
5  select name,bytes/1048576 from v$datafile;
6  set lines 500
7  r
8  select tablespace_name from dba_tablespaces;

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

SQL> hist 3 run
HOST_NAME
----------------------------------------------------------------
server1.example.com

The full usage of the history command


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.

OK, it`s not so cool as rlwrap, but it is better than nothing.
For more Information check the Oracle Documentation.

Hinterlasse einen Kommentar