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]“

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

The full usage of the history command

SQL> help history
Stores, lists, executes, edits of the commands
entered during the current SQL*Plus session.

N is the entry number listed in the history list.
Use this number to recall, edit or delete the command.

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.

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:


Du kommentierst mit Deinem WordPress.com-Konto. Abmelden /  Ändern )

Google Foto

Du kommentierst mit Deinem Google-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden /  Ändern )

Verbinde mit %s