Install SQLcl on Oracle Cloud Infrastructure Cloud Shell and make it work against an Autonomous Database
Cloud Shell on Oracle Cloud Infrastructure is a versatile management and development environment to access and manage Oracle Cloud Infrastructure resources. Cloud Shell comes with many tools and runtime out of the box (or rather inside the box) including OCI CLI, Java and SQL*Plus. However, the Oracle SQL Developer Command Line (SQLcl) tool — the Java-based replacement for SQL*Plus — is not part of the package (at the time of writing, 17th March 2020).
In this article I want to install SQLcl in Cloud Shell and use it against an Autonomous Database.
I have leaned heavily on Tim Scott’s article on installing SQLcl.
1. Go to https://www.oracle.com/tools/downloads/sqlcl-downloads.html and download SQLcl
Save the zip-file to your local computer.
2. Upload the zip-file to a location from where it can be download in Cloud Shell. OCI Object Storage is a good option; services such as Google Drive, Dropbox and OneDrive probably should do the trick as well.
3. Download the zip-file to Cloud Shell
oci os object get -bn bucket-01 --name sqlcl-18.104.22.1684.0937.zip --file sqlcl.zip
4. Extract the zip. This will create a directory sqlcl in the current directory
5. Set JAVA_HOME environment variable to refer to Java Runtime on Cloud Shell
Java is already installed on the Cloud Shell. It can be found in /ur/lib/jvm and the Java runtime — to which we need JAVA_HOME to refer — is in its jre sub directory. This brings JAVA_HOME to:
6. Set an alias — a short cut for starting SQLcl
7. Run SQLcl
With the alias defined, we can start SQLcl using a simple sql command. The /nolog switch means that we are not prompted for database login details.