If you would like to know more about the iDevelopment.info Newsletter, please email me.
Command History and Auto-Completion for SQL*Plus on Unix/Linux (29-December-2011)
Oracle sqlplus and rman are popular command-line interfaces that allow for quick and easy access to an Oracle instance. However, unlike most modern command-line tools like MySQL or PostgreSQL, Oracle's sqlplus and rman do not provide persistent command history or auto-completion functionality under Linux and Unix. For example, without command history, making a mistake when typing a long statement in sqlplus often means canceling out and re-entering it all over again. Powerful interfaces like the Unix/Linux bash shell offer auto-completion of the text you are typing (by pressing TAB), access to a history of previous commands (up/down arrows, or CTRL-P/CTRL-N), incremental search on the command history (CTRL-R), moving the cursor and modifying statements within the current line (left/right arrows), and persisting the command history in between invocations. Nearly all these tools use the GNU readline library to provide these capabilities. While not all command-line tools use the GNU readline library (like Oracle's sqlplus and rman), the good news is that these limitations can be easily overcome by using the rlwrap tool written by Hans Lub. The following paper presents examples of how to enhance some of Oracle's command-line utilities like SQL*Plus and RMAN with command history and auto-complete functionality on the Unix/Linux platform. http://www.idevelopment.info/data/Oracle/DBA_tips/SQL_PLUS/SQLPLUS_8.shtml ---------------------------- Jeffrey M. Hunter, OCP Sr. Database Administrator firstname.lastname@example.org http://www.idevelopment.info ----------------------------