The Oracle database client installation software is rather large in size.
$ ls -l *11g* -rw-r--r-- 1 rasti staff 642016988 2010-04-27 23:36 linux_11gR2_client.zip
Not only the approximate 630MB in size but also the graphical installation procedure is sometimes a big shortcoming. And for simply accessing an Oracle SQL Server a lesser volume of data might be sufficient too. There the Oracle Instant Client comes into play.
$ ls -l *11.2*
-rw-r--r-- 1 rasti staff 46299404 2010-03-19 16:10 oracle-instantclient11.2-basic-11.2.0.1.0-1.i386.rpm -rw-r--r-- 1 rasti staff 1564168 2010-03-19 16:10 oracle-instantclient11.2-jdbc-11.2.0.1.0-1.i386.rpm -rw-r--r-- 1 rasti staff 791567 2010-03-23 14:24 oracle-instantclient11.2-sqlplus-11.2.0.1.0-1.i386.rpm
After installation of these three software packages e.g. like this
$ rpm -ivh oracle-instantclient11.2-basic-11.2.0.1.0-1.i386.rpm $ rpm -ivh oracle-instantclient11.2-jdbc-11.2.0.1.0-1.i386.rpm $ rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.1.0-1.i386.rpm
You ought to see them as part of the installed software.
$ rpm -qa|grep -E “^oracle”
oracle-instantclient11.2-basic-11.2.0.1.0-1 oracle-instantclient11.2-jdbc-11.2.0.1.0-1 oracle-instantclient11.2-sqlplus-11.2.0.1.0-1
If not been redirected the installation of the libraries goes to the directory /usr/lib/oracle/11.2/client/lib
You can check the package content with
$ rpm -qil oracle-instantclient11.2-sqlplus-11.2.0.1.0-1.i386 ...
To make the tools finding their required libraries automatically linking is used frequently in the /usr/lib directory.
$ ls -l /usr/lib/liboc* /usr/lib/libsqlpl* lrwxrwxrwx 1 root root 38 2010-04-15 19:18 /usr/lib/libocci.so.11.1 -> oracle/11.2/client/lib/libocci.so.11.1 lrwxrwxrwx 1 root root 34 2010-03-23 14:36 /usr/lib/libociei.so -> oracle/11.2/client/lib/libociei.so lrwxrwxrwx 1 root root 38 2010-03-23 14:36 /usr/lib/libocijdbc11.so -> oracle/11.2/client/lib/libocijdbc11.so lrwxrwxrwx 1 root root 38 2010-03-23 14:36 /usr/lib/libsqlplusic.so -> oracle/11.2/client/lib/libsqlplusic.so lrwxrwxrwx 1 root root 36 2010-03-23 14:36 /usr/lib/libsqlplus.so -> oracle/11.2/client/lib/libsqlplus.so
Let’s assume we’d like to access the database HELLO and keep the connection description in the accustomed location. Thus we put the tnsnames.ora here …
$ mkdir -p /usr/lib/oracle/11.2/network/admin
$ cd /usr/lib/oracle/11.2/network/admin ; vi tnsnames.ora
...
$ cat tnsnames.ora
HELLO.WORLD = (
DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = hello.equitania.de)(PORT = 1527))
(CONNECT_DATA = (SERVER = DEDICATED)(SID = HELLO))
)To prepare the tools using this definition we hat the choice whether we’d like to append our settings to /etc/profile.local or create a seperate file for our needs like /etc/profile.d/sqlplus.
Either way we’ve added the following lines.
$ cat /etc/profile.d/sqlplus
ORACLE_HOME=/usr/lib/oracle/11.2
export ORACLE_HOME
TNS_ADMIN=${ORACLE_HOME}/network/admin
export TNS_ADMINAfter these variables had been sourced into the shell environment, we can logon to the database.
$ sqlplus /nolog SQL> CONNECT rasti/T0pS3cr3T@hello.world SQL> SELECT * FROM user_tables; ... SQL> disconnect; SQL> EXIT;
Very well, it worked properly!
Please consult the SQL*Plus FAQ for further information about the clients capabilities.
Please also bear in mind that the tnsnames.ora won’t be used if accessing the database by PHP via the OCI library for instance. In this case you must know exactly how the database is defined on the server host. You can’t redefine the connection attributes in the tnsnames.ora file.
