Bash aliases for SQLcl
- Written by: ilmarkerm
- Category: Blog entry
- Published: December 9, 2019
I have quite many different databases and would like to log in to them from my linux box using my AD username and password. Creating tnsnames.ora aliases for all of them is too much work, I’d like to just specify hostname and service from command line.
Bash aliases to the rescue, but simple alias is not enough in this case, so just take it as an example how can more complex aliases be created in Bash.
Just copy these functions to $HOME/.bashrc, modify them according to your needs and done 🙂
This creates two “aliases” – sqls for secure database connection and sql for insecure. I also need to use instantclient driver for database connection (Radius authentication).
Usage:
sqls rac-scan.example.com myapplicationservice.prod
sqls rac-scan.example.com myapplicationservice.prod dbauser
SQLS_OPTS="-verbose" sqls rac-scan.example.com myapplicationservice.prod