Saturday, September 15, 2012

How to Install Oracle's SQL*Plus in Ubuntu Without Instaling Oracle

SQL*Plus is an Oracle command-line utility program that can run SQL and PL/SQL commands interactively or from a script. Programmers and DBAs commonly use it as the default available fundamental interface in almost any Oracle software installation

Oracle does not provide .deb packages which are recognized by Ubuntu. Instead they provide .rpm packages. This tutorial tells how to install SQL*Plus without installing Oracle and using the .rpm packages in Ubuntu.

Follow these steps : 

1. Download the following .rpm packages from Oracle's website.

         a. Choose either 32 bit or 64 bit versions 
         b. Download Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications
         c. Download Instant Client Package - SQL*Plus: Additional libraries and executable for running SQL*Plus with Instant Client
         Remember to download the .rpm versions and NOT the .zip versions

2. Install the application alien to convert the .rpm packages to .deb. Install it by executing:



sudo apt-get install alien

3. CD to the folder containing the .rpm file

sudo alien -k oracle-instantclient*.rpm

4. The .deb files have been generated. Install them using 


sudo dpkg -i oracle-instantclient*basic*.deb
sudo dpkg -i oracle-instantclient*sqlplus*.deb

5. Add the library to classpath. 


$ vim ~/.bashrc

6. Add this line at the end of the file. Replace $version$ with the correct number.


export LD_LIBRARY_PATH=/usr/lib/oracle/$version$/client/lib


Now you can connect to any oracle installation using the command : 

       $ sqlplus username/password@hostname/orcl

Replace username, password, hostname, and orcl. Mostly the orcl will be "orcl" only.

No comments: