Showing posts with label Connect to Oracle database using command line on Ubuntu 16.04. Show all posts
Showing posts with label Connect to Oracle database using command line on Ubuntu 16.04. Show all posts

Saturday, August 8, 2020

Connect to Oracle database using command line on Ubuntu 16.04

1. Download Oracle client package (instantclient-basiclite-linux.x64-19.8.0.0.0dbru.zip) and sqlplus commandline client package (instantclient-sqlplus-linux.x64-19.8.0.0.0dbru.zip) from here
Your may have latest versions, download them.

2. Now run commands
mkdir -p /opt/oracle
cd /opt/oracle

3. Unzip downloaded package instantclient-basiclite-linux.x64-19.8.0.0.0dbru.zip
unzip instantclient-basiclite-linux.x64-19.8.0.0.0dbru.zip
and move folder instantclient_19_8 in /opt/oracle

4. Install libaio package
sudo apt install libaio-dev
5. Run Commands
sudo sh -c "echo /opt/oracle/instantclient_19_8 > /etc/ld.so.conf.d/oracle-instantclient.conf"
  
sudo ldconfig

or
export LD_LIBRARY_PATH=/opt/oracle/instantclient_19_8:$LD_LIBRARY_PATH
6. Unzip downloaded package instantclient-sqlplus-linux.x64-19.8.0.0.0dbru.zip
unzip instantclient-sqlplus-linux.x64-19.8.0.0.0dbru.zip
Copy all .so files of these extracted zip into /opt/oracle/instantclient_19_8
mv *.so /opt/oracle/instantclient_19_8
7. Now connect to oracle db on command line.
./sqlplus username/password@domain:port/service_name
Example :
./sqlplus root/strongpassword@54.24.xxx.xxx:1532/ORCAD
8. After connect to sql prompt, list all databases using query
select * from v$database;
Query to view the schema name by
select * from dba_users;
To display the columns available in the Oracle view v$database, we can execute the below statement.
desc v$database;