Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

13/4/2020 ADB HOL # 3-2: Connect with SQL * plus | Oracle Community

ADB HOL # 3-2: Let's connect with SQL * plus  Version 22

Created by TakeshiNagakubo-Oracle on Dec 17, 2019 5:58 AM.Last modified by TakeshiNagakubo-Oracle on Feb 17, 2020 2:47 AM.

Back to Contents : Tutorial: Get Started with Oracle Cloud Infrastructure


> Return to ADB Contents List : Autonomous Database Hands-on Lab

Let's check how to connect to Autonomous Database using SQL * plus.


Once you get used to working with credential wallets (the Credential.zip file), there's nothing special about being Autonomous.

This chapter assumes that the virtual machine created by this procedure is accessed using Tera Term.
Also, prepare the credentials file of the ADB instance to connect to in advance.

Workflow
1. Editing configuration files
2. Connect to ADB

Time required: about 10 minutes

1. Edit configuration file

1. Log in to the virtual machine prepared in advance as an opc user.

2. Upload the credential file on the virtual machine.


* The description here is based on Teraterm.

2-1. Start Tera Term and log in to the virtual machine as an opc user.

2-2. Drag and drop the credential file ( wallet_atp01.zip) onto the Tera Term window screen.

2-3. Click the SCP without specifying the destination folder .

2-4. Check the home directory of the opc user and confirm that Wallet_atp01.zip has been transferred. (If the file exists, it is OK.)

$ ls

3. Move the credential file uploaded earlier to the oracle user and change the file owner to the oracle user.
(* In this Hands-on Lab, you will experience various operations using the oracle user unless otherwise specified.)

$ sudo mv Wallet_atp01.zip / home / oracle / labs / wallets /.


$ sudo chown oracle: oinstall /home/oracle/labs/wallets/Wallet_atp01.zip

4. Switch to the oracle user.

https://community.oracle.com/docs/DOC-1035042 1/4
13/4/2020 ADB HOL # 3-2: Connect with SQL * plus | Oracle Community
$ sudo -s
$ su-oracle

(Switch to root user first, then switch to oracle user)

5. Extract the zip file under the directory "wallet_atp01".

$ unzip /home/oracle/labs/wallets/Wallet_atp01.zip -d ~ / labs / wallets

6. Set the TNS_ADMIN environment variable to the directory "wallet_atp01".

$ export TNS_ADMIN = / home / oracle / labs / wallets

NOTE) If you want to switch the instance to connect to each application, it is easy to define a directory such as wallets_atp01 for each
instance and switch the path of the environment variable TNS_ADMIN for each application.

7. Change to the $ HOME / wallets directory.

$ cd ~ / labs / wallets /

8. Edit the following in the sqlnet.ora file from the extracted files

Before editing: WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY = "? / Network / admin" )))
After editing: WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY = $ TNS_ADMIN )))

$ vi sqlnet.ora
<< Edit with vi >>

$ cat sqlnet.ora
WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY = $ TNS_ADMIN)))
SSL_SERVER_DN_MATCH = yes
$

[Reference] How to use vi


Up / Down / Left / Right keys Move the cursor location
i Edit from cursor position (enter InsertMode)
Exit ESC key InsertMode
x Erase one character at the cursor position
: wq Save and close file
: q Close file (the previous edits are discarded)
: q! force exit

2. Connect to ADB

1. Start SQL * Plus on ADB as shown below.

$ sqlplus admin / Welcome12345 # @ atp01_low

username: admin
password: Welcome12345 # (value specified when creating the instance)

https://community.oracle.com/docs/DOC-1035042 2/4
13/4/2020 ADB HOL # 3-2: Connect with SQL * plus | Oracle Community
conn_string: atp01_low (connection service name)

* For details on connection services, please refer to technical details or here .

2. Execute the sample command as a trial. Here we are checking the version of this instance as an example.

SQL> select version from v $ instance;

3. If you can connect without error, close SQL * Plus.

SQL> exit

3. Connect to ADB with SQLcl


SQLcl is a free command line tool. ( Click here for SQLcl )

Similar to SQL * Plus but with more features than SQL * Plus
Easy connection to Autonomous Database.

1. Start SQLcl.

$ sql / nolog

2. Specify the wallet.

SQL> set cloudconfig /home/oracle/labs/wallets/Wallet_atp01.zip

3. Connect.

SQL> connect admin / Welcome12345 # @ atp01_low

This concludes the work in this chapter.

Proceed to the next chapter.


ADB HOL # 4-1: Migrate Existing Oracle Database to Autonomous Database

168 Views Categories: Autonomous Database Tags:

Average User Rating

(0 ratings)

0 Comments

https://community.oracle.com/docs/DOC-1035042 3/4
13/4/2020 ADB HOL # 3-2: Connect with SQL * plus | Oracle Community

Oracle Community

   
About Oracle Developer Community FAQ Communities Other Languages Oracle.com

Site Map Legal Notices Terms of Use Privacy Cookie Preferences Ad Choices

https://community.oracle.com/docs/DOC-1035042 4/4

You might also like