Connect to Autonomous Database on Dedicated Exadata Infrastructure with Oracle SQLcl

Tip:

For a "try it out" alternative that demonstrates these instructions, run Task 4: Connect to your autonomous DB using SQL Worksheets from Database Actions, SQLCL and SQL Plus from Lab 2: Configure a Development System in the Oracle Autonomous Database Dedicated Workshop.
SQLcl (Oracle SQL Developer Command Line) is a command-line interface for Oracle Database. It allows you to interactively or batch execute SQL and PL/SQL. SQLcl provides in-line editing, statement completion, and command recall for a feature-rich experience, all while also supporting your previously written SQL*Plus scripts.
To be able to connect SQLCl to an Autonomous Database, the system running SQLCl must have network access to the Autonomous Database. This can be achieved using either of the following ways:

You can use SQLcl version 4.2 or later with Autonomous Database. Download SQLcl from oracle.com.

SQLcl can connect to an Autonomous Database using either an Oracle Call Interface (OCI) or a JDBC thin connection.

SQLcl with Oracle Call Interface

To connect using Oracle Call Interface, use the –oci option, supply the database user name, a password, and the database service name provided in the tnsnames.ora file. For example:

sql -oci

SQLcl: Release 19.1 Production on Mon Jan 18 09:28:38 2021

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

Username? (''?) sales_trans@atpc1_low
Password? (**********?) **************
Last Successful login time: Mon Jan 17 2019 15:29:19 -07:00

Connected to:
Oracle Database 19c EE Extreme Perf Release 19.0.0.0.0 - Production
Version 19.9.0.0.0

SQL>

When connecting using Oracle Call Interface, the Oracle Wallet is transparent to SQLcl.

SQLcl with a JDBC Thin Connection

To connect using a JDBC Thin connection, first configure the SQLcl cloud configuration and then connect to the Autonomous Database.

  1. Start SQLcl with the /nolog option.
    sql /nolog
    
  2. Configure the SQLcl session to use your Oracle Wallet:
    SQL> set cloudconfig directory/client_credentials.zip
    Wallet Password:  **********
  3. Connect to the Autonomous Database:
    SQL> connect username@servicename
    password

    For example:

    sql /nolog
    
    SQLcl: Release 19.1 Production on Mon Jan 18 09:28:38 2021
    
    Copyright (c) 1982, 2021, Oracle.  All rights reserved.
    
    SQL> set cloudconfig /home/atpc/wallet_ATPC.zip
    Operation is successfully completed.
    Operation is successfully completed.
    Using temp directory:/tmp/oracle_cloud_config3643858537577169472
    
    SQL> connect admin@atpc_medium
    Password? (**********?) ************
    Connected.

For more information, on the connection types specified in tnsnames.ora, see Predefined Database Service Names for Autonomous Databases.

For information on SQLcl, see Oracle SQLcl.