2.2 About the CONNECT Command
Use the CONNECT command to connect to a database.
Syntax
conn[ect] {OPTIONS} {PARAMETERS}
The options specified automatically determine the kind of connection required,
such as whether it is a traditional client-server connection or a wallet-based cloud
connection. You can override this by using options that specify a particular connection
type. For example, specify -wallet to use the wallet connection type.
The connection types supported in SQLcl are:
- KERBEROS
- NAME
- OCI
- ORACLE
- OREST
- RADIUS
- SOCKS
- THIRD
- WALLET
To see the help description for CONNECT, enter:
help connect
To see examples for CONNECT in help, enter:
help connect examples
To see help for WALLET connection type, enter:
help connect wallet
To see examples for OREST, enter:
help connect orest examples
Options
| Option | Description |
|---|---|
| -cloudconfig, cc | Specifies the wallet to use to establish the connection. |
| -edition, ed | Specifies the Oracle database edition. This is an alternative to providing it in the connection spec parameter. |
| -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. |
| -krb5ccname, krb5cc | Specifies a non-default Kerberos credential file. |
| -name, n | Specifies a Name connection type. |
| -oci | Specifies an OCI connection type. |
| -oracle, o | Specifies an Oracle connection type. |
| -orest, or | Specifies a REST connection type. |
| -password, pw | Specifies the password. This is an alternative to providing it in the connection spec parameter. |
| -proxy, p | Specifies the network proxy to use. |
| -radius, rad | Specifies a RADIUS connection type. |
| -replace, rp | Specifies that the saved connection details must replace any
existing connection with the same name. Requires the -save
option.
|
| -rest, rt | Specifies that the connection should be established using REST. |
| -role, r | Specifies the database role. This is an alternative to providing it in the connection spec parameter. |
| -save, sa | Specifies a name to save the connection details for a successful connection. |
| -savepwd, sv | Specifies that passwords must be saved with the connection details.
By default, passwords are not saved. Requires the -save
option.
|
| -socks|s | Specifies a SOCKS proxy connection type. |
| -socksproxy|sp | Specifies the SOCKS proxy. |
| -third, t | Specifies a third-party database connection type. |
| -url | Specifies the URL. This is an alternative to providing it in the connection spec parameter. |
| -user, u | Specifies the user name. This is an alternative to providing it in the connection spec parameter. |
| -wallet, w | Specifies a wallet connection type. |
| -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 to an Oracle database:
SQL> CONNECT user/password@url
To connect to an Oracle database using the SYSDBA role:
SQL> CONNECT user/password@url as sysdba
To save a connection after opening it:
SQL> CONNECT -SAVE myconn scott@localhost:1521/orcl