SQLcl host Command

Oracle SQLcl is the command line tool to connect to an Oracle database. One neat feature it has is the ability to call host commands (i.e call terminal commands directly from SQLcl). You can use any of the following to trigger a host command:

host
ho
!

Examples:

sql /nolog

-- Full command name
SQL> host ls
dist        README.md    src

-- Short name
SQL> ho ls
dist        README.md    src

-- Really short name: (optional space between ! and the command you want to run)
SQL> !ls
dist        README.md    src

Personally I like using the shortcut ! reference as it’s very quick to write when doing a lot of scripting.

The host command can be really useful is when working with the new SQLcl CI/CD tool Projects. You can quickly see the status of the git repo using !git status rather than having to exit SQLcl, run the command, then go back into SQLcl.

1
Subscribe to my newsletter

Read articles from Martin Giffy D'Souza directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Martin Giffy D'Souza
Martin Giffy D'Souza