CS345 - Topics in Data Warehousing
Autumn 2004

Oracle Resources
The following are useful web resources for Oracle information:
  • CS145 Oracle Tips Page The first place to look. Good tutorial information about common issues, specific to the Stanford environment.
  • Oracle FAQ Frequently asked questions web site provided by Oracle.
  • Google Answers to many Oracle questions can be found easily using Google. Example: to learn about SQL*Loader, do a search for "oracle sql loader"
Oracle clients

There are a number of client programs that allow you to interactively issue SQL statements to Oracle. Here is some information about a few of them.

  • sqlplus The sqlplus program is Oracle's terminal-based command-line SQL interface. The advantage of using sqlplus is that it is very easy to get started: (1) Log onto one of Stanford's UNIX machines, (2) type "source /usr/class/cs345/all.env", (3) type "sqlplus", (4) enter your username and password when prompted, (5) type in a SQL statment, terminated with a semicolon. The disadvantages of sqlplus is that it is very clunky, has poor text editing capabilities, and does a horrible job formatting large query results.
  • TOAD TOAD is a free Oracle client program for Microsoft Windows. The advantage of using TOAD is that it has a nice graphical interface and is easy to use. The disadvantage of TOAD is that you have to do a bunch of work to install it and set it up before you can start using it.
  • TOra TOra is a free, open-source Oracle client program for Linux and Windows. TOra is very similar to TOAD and has the same advantages and disadvantages.
If you own a Windows or Linux computer that you use for schoolwork, installing TOAD or TOra is recommended, because it will probably make your life easier in the long run. However, it is possible to get by with sqlplus if you don't want to put up with the hassle of installing one of the other programs. Here are the steps to install TOAD (TOra is similar):
  1. Download TOAD and uncompress it into some directory.
  2. Download the Oracle Instant Client, "Basic" package, for the appropriate platform (Windows or Linux). You will have to register with Oracle TechNet to do the download, but it's free of charge.
  3. Create an "oracle" directory on your computer with subdirectories name "bin" and "network". Within the "network" directory create a subdirectory called "admin".
  4. Uncompress the Oracle Instant Client package and place its contents in the "bin" subdirectory.
  5. The next two steps are for installing TOAD. If you're installing TOra, then read this instead.
  6. Run the "regedit" Windows program (e.g. select "Run" from the Start menu and type "regedit"). Under the key HKEY_LOCAL_MACHINE/SOFTWARE, create a new key named "ORACLE". Under the "ORACLE" key, create a String value named ORACLE_HOME and set its value to be the path to the "oracle" directory you created earlier. (See this page for more details.)
  7. Add these environment variables (in Windows XP, go to the Advanced tab under "My Computer"): SQL_PATH=the path to your oracle directory, LD_LIBRARY_PATH=the path to your oracle directory, TNS_ADMIN=the path to your oracle/network/admin subdirectory.
  8. Copy the file tnsnames.ora from /usr/class/cs345/sqlnet to your own machine and place it in the oracle/network/admin subdirectory.
After following the above steps, you should be able to run TOAD -- contact the instructor if you have problems.
Oracle programming models
There are various ways to issue SQL statements to Oracle from programs written in C, Java, or other languages. Here are three of them:
  • Java Database Connectivity JDBC allows Java programmers to issue SQL statements. The CS 145 JDBC tutorial and Sun JDBC tutorial explain how JDBC works. The HelloWorld.java file will get you started.
  • Oracle Call Interface OCI allows C programmers to issue SQL statements. Oracle's OCI FAQ and the Oracle documentation describe how to use OCI. OCI sample code can be found on the Sweet Hall machines (e.g. the elaines) at /usr/pubsw/apps/oracle/8.1.7/rdbms/demo.
  • Pro*C Precompiler Pro*C is another method for issuing SQL statements from C programs. The CS 145 Pro*C tutorial explains how to use Pro*C.