9.7 CONNECT

Connection types in SQLcl:

9.7.1 KERBEROS Connection Type

Connect to a database using Kerberos authentication. The connection spec parameter has the following form:

[/][@<url>]

Note:

Only Kerberos connections using [/][@<url>] are supported in SQLcl. Active Directory is not supported.

See Enabling Kerberos Authentication in Oracle Database Security Guide for more information about Kerberos authentication in Oracle Database.

Options

Option Description
-kerberos, ker Specifies a KERBEROS connection type.
-krb5_config, krb5c Specifies a non-default Kerberos configuration file. This property is specified only when SQLcl is started. These can be passed in by using the relevant -D system property name or environmental variables.
-krb5ccname, krb5cc Specifies a non-default Kerberos credential file.
-url Specifies the URL. This is an alternative to providing it in the connection spec parameter.
-role, r Specifies the database role. This is an alternative to providing it in the connection spec parameter.
-edition, ed Specifies the Oracle database edition. This is an alternative to providing it in the connection spec parameter.
-verbose, v Requests output of diagnostic information about the connection.

Parameters

Parameter Description
<connectionspec> Provides the connection specification for the target database.

Example

To connect to a database using KERBEROS:

SQL> CONNECT -kerberos /@myhost:1521/myservice

See Also:

Support for Kerberos for troubleshooting information

9.7.2 NAME Connection Type

Connect to a database using a stored connection definition. Stored connections are identified using a unique connection name. For more information about stored connections, see CONMGR.

Options

Option Description
-name, n Specifies a connection type using a stored connection definition.
-user, u Specifies the user name. This is an alternative to providing it in the connection spec parameter.
-url Specifies the URL. This is an alternative to providing it in the connection spec parameter.
-password, pw Specifies the password. This is an alternative to providing it in the connection spec parameter.
-role, r Specifies the database role. This is an alternative to providing it in the connection spec parameter.
-edition, ed Specifies the Oracle database edition. This is an alternative to providing it in the connection spec parameter.
-verbose, v Requests output of diagnostic information about the connection.

Parameters

Parameter Description
<connectionspec> Provides the connection specification for the target database.

Examples

To connect using a stored connection:

SQL> CONNECT -name my_connection

To connect using a stored connection as a different user:

SQL> CONNECT -name myuser/mypassword@my_connection

or

SQL> CONNECT -name myuser@my_connection

9.7.3 OCI Connection Type

Connect to a database using OCI. Before connecting to OCI, it is necessary to specify the profile to use. For example, OCI PROFILE frankfurt.

The connection spec parameter has the following form:

ocid1.databasetoolsconnection.<id>.

Options

Option Description
-oci Specifies an OCI connection type.
-rest, rt Specifies that the connection should be established using REST.
-proxy, p Specifies the network proxy to use.
-verbose, v Requests output of diagnostic information about the connection.

Parameters

Parameter Description
<connectionspec> Provides the connection specification for the target database.

Example

To connect using an OCID:

SQL> CONNECT ocid1.databasetoolsconnection.oc1.xxxyyyyzz.aabbccd

9.7.4 Oracle Connection Type

Connect to a database using Oracle Relational Database Management System.

The connection spec parameter has the following form:

<username>[/<password>][@<url>][as <role>][edition= <edition>]

where

  • <username> may be <proxyuser>[<username>] if a proxy user is required. Note that the brackets around user name are required syntax.

  • The <url> can take either of the following forms:

    //<host>:<port>/<service> 
    <host>:<port>/<service>

    or it may be a TNS name or an LDAP specification.

Options

Option Description
-oracle, o Specifies an Oracle connection type.
-user, u Specifies the user name. This is an alternative to providing it in the connection spec parameter.
-password, pw Specifies the password. This is an alternative to providing it in the connection spec parameter.
-url Specifies the URL. This is an alternative to providing it in the connection spec parameter.
-role, r Specifies the database role. This is an alternative to providing it in the connection spec parameter.
-edition, ed Specifies the Oracle database edition. This is an alternative to providing it in the connection spec parameter.
-verbose, v Requests output of diagnostic information about the connection.

Parameters

Parameter Description
<connectionspec> Provides the connection specification for the target database.

Example

To connect using EZCONNECT:

SQL> CONNECT myuser/passwd@myhost:1521/myservice

9.7.5 OREST Connection Type

Connect to a database using REST. The connection spec parameter has the form:

<username>[/<password>][@<url>][as <role>][edition= <edition>]

The <url> can take the form:

http://<host>:<port>/ords/<schema>

Options

Option Description
-orest, or Specifies a connection type that uses REST.
-user, u Specifies the user name. This is an alternative to providing it in the connection spec parameter.
-password, pw Specifies the password. This is an alternative to providing it in the connection spec parameter.
-url Specifies the URL. This is an alternative to providing it in the connection spec parameter.
-role, r Specifies the database role. This is an alternative to providing it in the connection spec parameter.
-edition, ed Specifies the Oracle database edition. This is an alternative to providing it in the connection spec parameter.
-verbose, v Requests output of diagnostic information about the connection.

Parameters

Parameter Description
<connectionspec> Provides the connection specification for the target database.

Example

To connect using REST:

SQL> CONNECT myuser/passwd@http://myhost:9213/ords/myschema

9.7.6 RADIUS Connection Type

Connect to a database using RADIUS authentication. The connection spec parameter has the form:

[<username>][/<password>][@<url>]

RADIUS can also be configured to authenticate using <number> from two-factor authenication:

[<username>]/[<password>][<number from device or command>][<@url>]

Note:

Challenge response two-factor authentication for RADIUS is not supported in this release.

See Configuring RADIUS Authentication in Oracle Database Security Guide for more information about RADIUS authentication.

Options

Option Description
-radius, rad Specifies a RADIUS connection type.
-user, u Specifies the user name. This is an alternative to providing it in the connection spec parameter.
-password, pw Specifies the password. This is an alternative to providing it in the connection spec parameter.
-url Specifies the URL. This is an alternative to providing it in the connection spec parameter.
-role, r Specifies the database role. This is an alternative to providing it in the connection spec parameter.
-edition, ed Specifies the Oracle database edition. This is an alternative to providing it in the connection spec parameter.
-verbose, v Requests output of diagnostic information about the connection.

Parameters

Parameter Description
<connectionspec> Provides the connection specification for the target database.

Example

To connect using RADIUS:

SQL> CONNECT -radius myuser/passwd@myhost:1521/myservice

See Also:

9.7.7 SOCKS Connection Type

Connect to a database using a SOCKS proxy. Before connecting, set up the proxy process on the local machine by using the ssh command. For example:

ssh -N -D 127.0.0.1:1087 
opc@123.456.789.120.

The connection spec parameter has the form:

[<username>][/<password>][@<url>]

Options

Option Description
-socks|s Specifies a SOCKS connection type.
-socksproxy|sp Specifies the socks proxy.
-cloudconfig, cc Specifies the wallet to establish the connection.
-proxy, p Specifies the network proxy to use.
-user, u Specifies the user name. This is an alternative to providing it in the connection spec parameter.
-password, pw Specifies the password. This is an alternative to providing it in the connection spec parameter.
-url Specifies the URL. This is an alternative to providing it in the connection spec parameter.
-role, r Specifies the database role. This is an alternative to providing it in the connection spec parameter.
-edition, ed Specifies the Oracle database edition. This is an alternative to providing it in the connection spec parameter.
-verbose, v Requests output of diagnostic information about the connection.

Parameters

Parameter Description
<connectionspec> Provides the connection specification for the target database.

Example

To set the SOCKS and wallet properties and then connect:

 SQL> SET socksproxy socks5h://localhost:1080
  SQL> SET cloudconfig mywallet.zip
  SQL> CONNECT myuser/passwd@mycloudtns

Alternatively, do it using one command:

SQL> CONNECT -socksproxy socks5h://localhost:1080 -cloudconfig mywallet.zip
  myuser/passwd@mycloudtns

9.7.8 THIRD Connection Type

Connect to a third-party database. You need to add the appropriate driver jar to <sqlcl-root>/lib/drivers/. For example, for MYSQL you can download mysql-connector-java-8.0.30.jar.

The connection spec parameter is specific to the database but generally takes the form:

<username>[/<password>]@jdbc:<dbtype>://<host>:<port>

Options

Option Description
-third, t Specifies a THIRD connection type.
-user, u Specifies the user name. This is an alternative to providing it in the connection spec parameter.
-password, pw Specifies the password. This is an alternative to providing it in the connection spec parameter.
-url Specifies the URL. This is an alternative to providing it in the connection spec parameter.
-role, r Specifies the database role. This is an alternative to providing it in the connection spec parameter.
-edition, ed Specifies the Oracle database edition. This is an alternative to providing it in the connection spec parameter.
-verbose, v Requests output of diagnostic information about the connection.

Parameters

Parameter Description
<connectionspec> Provides the connection specification for the target database.

Example

To connect to MySQL:

SQL> CONNECT myuser/passwd@jdbc:mysql://myhost:9906

9.7.9 WALLET Connection Type

Connect to a database using a wallet. The connection spec parameter has the form:

[<username>][/<password>][@<url>]

Options

Option Description
-wallet, w Specifies a WALLET connection type.
-cloudconfig, cc Specifies the wallet to establish the connection.
-proxy, p Specifies the network proxy to use.
-user, u Specifies the user name. This is an alternative to providing it in the connection spec parameter.
-password, pw Specifies the password. This is an alternative to providing it in the connection spec parameter.
-url Specifies the URL. This is an alternative to providing it in the connection spec parameter.
-role, r Specifies the database role. This is an alternative to providing it in the connection spec parameter.
-edition, ed Specifies the Oracle database edition. This is an alternative to providing it in the connection spec parameter.
-verbose, v Requests output of diagnostic information about the connection.

Parameters

Parameter Description
<connectionspec> Provides the connection specification for the target database.

Example

To set the wallet property and then connect:

SQL> SET cloudconfig mywallet.zip
SQL> CONNECT myuser/passwd@mycloudtns

Alternatively, do it using one command:

SQL> CONNECT -cloudconfig mywallet.zip myuser/passwd@mycloudtns