Oracle 12.2 New Feature: SQL*Plus History

While playing with Oracle 12.2 Database on the Oracle Cloud, I noticed that SQL*Plus has a 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. Its usage and functionality is very similar to Unix history tool, but do not think that pressing the UP arrow will return to previous commands 🙂

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

After you issue the above command, all commands (except history commands) will be stored in the history list. The default length of the history list is 100. It means it stores 100 entries, and then first entry will be deleted to make space for the 101st one. You can write a number instead of “on” keyword, so the number will be the size of the history. For example, “set hist 10” command will enable history which will keep only last 10 entries.

You can run “show hist” to be sure that the history is enabled:

You can list all entries in the history list by running “hist[ory]”, and run any command by its number:

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

As I see, it keeps the commands in memory, it doesn’t store it in a file like Unix shells do. So after you exit from SQL*Plus, history is cleared.

For more information, you can check oracle documentation

Please share this post Share on Facebook0Share on Google+0Share on LinkedIn23Share on Reddit0Tweet about this on Twitter

Gokhan Atil is a database administrator who has hands-on experience with both RDBMS and noSQL databases (Oracle, PostgreSQL, Microsoft SQL Server, Sybase IQ, MySQL, Cassandra, MongoDB and ElasticSearch), and strong background on software development. He is certified as Oracle Certified Professional (OCP) and is awarded as Oracle ACE (in 2011) and Oracle ACE Director (in 2016) for his continuous contributions to the Oracle users community.

4 Comments

  1. Jagjeet Singh

    cool, but looks like very primitive.. would like to see more rlwrap features…

    Thanks

    • Gokhan Atil

      It’s not released yet, but you can create a trial account on Oracle Cloud so you can access Oracle DB 12.2.

Leave Comment

Your email address will not be published. Required fields are marked *