History and auto-completion with rlwrap 4

Posted by F 18/01/2007 at 23h06

If you ever used Oracle’s sqlplus you’d agree that it provides an arcane command-line interface.

Being a textmode command-line tool is not what makes it arcane though. It’s that it doesn’t offer auto-completion or a command history. If you made a small mistake when typing a long statement, you would have to re-enter it all over again.

Most modern command-line tools (including MySQL and PostgreSQL’s equivalent to Oracle’s sqlplus) provide much more powerful interfaces, just like the bash shell does. They include auto-completion of the text you are typing (by pressing TAB), access to a history of commands (up/down arrows, or C-p/C-n), incremental search on the history (C-r), they remember the history in between invocations and more. Virtually all these tools use the GNU readline library to provide these capabilities.

Unfortunately, not all command-line tools use GNU readline (splplus being one). Fortunately, there’s rlwrap. I just came to know this nice little tool.

rlwrap “wraps” any other command-line tool and gives you a readline interface to it. So, you can invoke rlwrap sqlplus and you get sqlplus with the history capabilities of the readline library.

You may also pass to rlwrap a list of potential words to use for completion. For example, I also use rlwrap with groovysh (the Groovy language shell), so I created a file “~/.groovysh_completions” containing the list of commands groovysh accepts. Now, when I launch groovysh I get command history and specialized auto-completion.

Now, rlwrap cannot do magic. Being so generic, it cannot do intelligent context-dependent auto-completion. For instance, PostgreSQL’s command-line interface automatically pulls the list of potential table names after doing SELECT * FROM <TAB>. rlwrap cannot give this intelligence to sqlplus, but it’s still much better than nothing.

Oracle DB Express 2

Posted by F 01/11/2005 at 16h45

I just realized about an interesting move from Oracle. They released a Beta version of their new Oracle Database 10g Express Edition.

This Express edition is free of charge. It is free not only for production use, but also for distribution.

These are the limitations it has: * It restricts itself to use only one CPU * Only one server and database instance (SID) per installation * Database size limit of 4GB

Looks like a good deal for ISVs, developers and small shops. It’s a good way for getting more mind-share among small software companies and younger/future developers.

I tried it on my Linux laptop and got it up and running in a couple of minutes. The Express name does not make it any lighter though: it still consumes a good chunk of RAM, and the database instance allocates 1GB of disk. So I’ll stick to PostgreSQL for powering this blog :-).