Log in

Registration

Oracle at Command Line

Posted: December 21, 2010 / in: Nuts and Bolts / No comments

db-oracleIf you are required to interface with an Orcale database instance at command line you have to provide some details to database tools that are contained in Oracle database installations or Oracle client suites. Otherwise you will receive some ugly error messages.

This article contains a general recipe how to find the required information and what to do with it.

Overview

Command line tools contained in Oracle software packages are required to read details regarding their runtime environment from process variables. The Oracle Corp. surly knows why developers were not able to fetch these information when starting up applications and for sure there are some reasons for that…

However, when installing a new database or an Oracle client the profile of the utilized system user is updated to contain the required data. But you will get into trouble if your are performing multiple database installations with the same user account or if you are required to utilize another system account to run tools like sqlplus.

The solution for problems like these is quite simple. You just have to …

  • locate the installation of the database or client suite
  • create a script file containing the required settings
  • apply the settings to your current shell before utilizing the tools of your desire

The following output contains an example for a command line session where the process environment has not been setup correctly and an error message has been generated when calling tools part of an Oracle Database Enterprise revision.

# change working directory and run 'sqlplus'$ cd /app/ris/oracle/1020/product/10.2.0/bin$ ./sqlplusError 6 initializing SQL*PlusMessage file sp1<lang>.msb not foundSP2-0750: You may need to set ORACLE_HOME to your Oracle software directory 

Locate the Installation

Most of the time you will know there the client suite or the database is located. If you do not know, you have to utilize tools like ‘locate’ or ‘find’ to get a list of available installations. In the latter case you may look for known files like ‘tnsnames.ora‘ or ‘sqlplus‘.

Create a Script File

It is assumed that you are required to start the application of desire from command line. In this case you may create a script file containing all required settings. The script file will contain settings that are specific to individual installations of databases or client suites. By ‘sourcing in‘ the new script file you will customize your current shell to hold all settings required to interact with your command line tool.

The following example is related to the Oracle Database release 9.2.0. But the same or a similar approach can be utilized to interface with revisions 8, 10, 11, 12, … at platform specific architectures supporting 32, 64, … bits.

# eample for Oracle 9.2.0 at a 32-bit architectureORACLE_BASE=/app/rrgw/oracle/920ORACLE_BIN=/app/rrgw/oracle/920/product/9.2.0/binORACLE_HOME=/app/rrgw/oracle/920/product/9.2.0ORACLE_LIB32=/app/rrgw/oracle/920/product/9.2.0/lib32export ORACLE_BASE ORACLE_BIN ORACLE_HOME ORACLE_LIB32 

Apply the Settings to your Shell

To ‘source in‘ the file containing the previous settings there are several approaches available. If you are utilizing the Bash you may execute the following statement.

 

# 'source in' a settings to your current bash shell$ . myscript.sh$ 

 

Now you are ready to start utilizing Oracle command line tools.

Good luck!

Incoming search terms:

© Copyrights and Licenses, 2012 - Linux-Support.com The Professional Linux and OSS Services Portal