From oracle.com:
SQLcl is a command-line interface for Oracle Database that combines the power of SQL*Plus and SQL Developer.
SQLcl is now under the Oracle Free Use Terms and Conditions license, which makes automated installation much easier.
Java is required, so ensure an appropriate version is installed.
- macOS OpenJDK Homebrew formula.
- Linux OpenJDK installation.
- Adoptium also offers prebuilt OpenJDK binaries for many platforms.
Use Homebrew as follows or use the shell script.
brew install --cask sqlcl
Note that this may not add the bin
folder to PATH
, so try the command on the Homebrew page and restart the shell.
Alternatively, add the command to ~/.zshrc
:
# Set path variables.
path+=$(brew --prefix)/Caskroom/sqlcl/<version>/sqlcl/bin
export path
typeset -U path
Use yum
as follows or use the shell script.
See the Oracle Linux Yum Server for assistance with yum
repositories.
sudo yum install sqlcl
❗ Use at your own risk. It is advisable to review the script before executing it.
-
Clone this repository and treat the root as the working directory.
cd ~ mkdir git cd git git clone <url>
-
The script may ask for the current user's password, as it will attempt to install SQLcl to
/opt
.$ sh install.sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 39.4M 100 39.4M 0 0 8721k 0 0:00:04 0:00:04 --:--:-- 8900k Installation complete
-
Restart the shell. E.g.
zsh
:exec zsh
-
Check the SQLcl install.
$ which sql /usr/local/bin/sql $ echo $SQLPATH /Users/<user>/.sqlcl $ echo $TNS_ADMIN /Users/<user>/.sqlcl
For example, using an instance of Oracle XE in a container:
-
Check the container is running.
$ podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6c5800535262 docker.io/gvenzl/oracle-xe:slim 8 seconds ago Up 8 seconds ago 0.0.0.0:1521->1521/tcp pensive_khorana
-
Connect to database as
system
user.$ sql system@localhost:1521/XEPDB1 SQLcl: Release 22.2 Production on Sat Jul 09 12:34:00 2022 Copyright (c) 1982, 2022, Oracle. All rights reserved. Password? (**********?) ***** Last Successful login time: Sat Jul 09 2022 12:34:05 +01:00 Connected to: Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production Version 21.3.0.0.0 SQL>
-
Optionally create a TNS entry in
$TNS_ADMIN/tnsnames.ora
.XEPDB1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = localhost) (PORT = 1521) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XEPDB1) ) )
Then connect using the entry:
sql system@XEPDB1
Create an account and an Autonomous Transaction Processing (ATP) database at https://cloud.oracle.com.
-
Select the database instance from the Autonomous Database dashboard.
-
Click DB Connection and download the Instance Wallet to
~/.sqlcl
.
E.g.~/.sqlcl/Wallet_demo.zip
. -
Open SQLcl:
sql /nolog
-
Load wallet:
SQL> SET CLOUDCONFIG Wallet_demo.zip Operation is successfully completed. Using temp directory:/var/folders/2v/jfse9ffs3sdfdfhde431dgge0000fr/T/oracle_cloud_config8573768666928582556
-
Check TNS entries:
SQL> SHOW TNS TNS_ADMIN set to: /var/folders/2v/jfse9ffs3sdfdfhde431dgge0000fr/T/oracle_cloud_config8573768666928582556 Available TNS Entries --------------------- demo_high demo_low demo_medium demo_tp demo_tpurgent
-
Connect to database using a TNS entry:
SQL> CONNECT admin@demo_medium Password? (**********?) ********************* Connected.
-
Execute some SQL:
SQL> SELECT SYSDATE 2 FROM dual; SYSDATE ____________ 01-JUL-22