8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » Misc » Here

SQLcl : Installation

The Oracle SQL Developer Command Line (SQLcl) tool is a Java-based replacement for SQL*Plus. No need to worry about client installations. Just download the app and go. This short post describes the simple process to install SQLcl.

Related articles.

Downloads

SQLcl requires a Java installation. That's probably going to be present on most servers anyway, but we'll assume it's not in this case.

Installation

We're going to install everything in our home directory, but you can put them anywhere.

# Install Java
mkdir ~/java
cd ~/java
tar -xf /tmp/openjdk-11.0.1_linux-x64_bin.tar.gz
ln -s ./j* ./latest

# Install SQLcl
cd ~
unzip -oq /tmp/sqlcl-18.3.0.259.2029.zip

Use It

To start SQLcl we need to make sure the JAVA_HOME environment variable is set, then run the "sql" script. I like to create an alias called "sql", but you could also put this location into your PATH environment variable.

export JAVA_HOME=${HOME}/java/latest
alias sql="${HOME}/sqlcl/bin/sql"

Now we can run SQLcl as follows.

sql /nolog

SQLcl: Release 18.3 Production on Sun Jan 13 09:29:26 2019

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


SQL>

TNS_ADMIN

You can make connections to databases using the EZ Connect URL.

CONN scott/tiger@//myhost.example.com:1521/myservice

If you would prefer to use a "tnsnames.ora" file, you can do that too. Just set the TNS_ADMIN environment variable to the directory holding the file and it will work as expected. For example, imagine I had a "tnsnames.ora" file in my home directory with the following contents.

myservice= 
(DESCRIPTION = 
  (ADDRESS = (PROTOCOL = TCP)(HOST = myhost.example.com)(PORT = 1521))
  (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = myservice)
  )
)

I would do the following.

export TNS_ADMIN=${HOME}

sql scott/tiger@myservice

Notes

You can get this error if you use an unsupported version of Java.

Exception in thread "main" java.lang.UnsupportedClassVersionError: oracle/dbtools/raptor/scriptrunner/cmdline/SqlCli : Unsupported major.minor version 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.  Program will exit.

The solution is to make sure the correct version of Java is being used. I've seen situations where the Java installation in the ORACLE_HOME has taken priority over that in the JAVA_HOME location. It's also possible the PATH environment variable can confuse matters. If you are having problems, you might want to try the following.

unset ORACLE_HOME
export JAVA_HOME=${HOME}/java/latest
export PATH=$JAVA_HOME/bin:$PATH

${HOME}/sqlcl/bin/sql

For more information see:

Hope this helps. Regards Tim...

Back to the Top.