Tips on using Oracle SQLPLUS at UWE

Chris Wallace Jan 2003

Starting SQLPLUS

From the command prompt on UNIX:

      SQLPLUS username/password
You can execute a file of commands as follows:
     
      SQLPLUS username/password < filename
      

This may be more convenient than entering commands with SQLPLUS because its easier to re-execute a set of commands, thanks to the Unix history.

From Windows, use the SQLPLUS tool to log in (host string is CEMS901). I'm not sure where scripts are read from, but you can cut and paste commands into the SQLPlus window.

Using SQLPLUS

Enter commands at the prompt. Commands in SQLPLUS are case-insensitive

Using scripts

Since line editing is minimal, it is much easier to use an editor to create/modify a command or sequence of commands and then load these into SQLPLUS. This works even for a single select statement as well as a complex script defining several tables, a number of INSERT statements to load data into a table or even a query

Create the commands in any editor. Save the file with a .SQL suffix.

In SQLPLUS, load the file, from the current directory on Unix, with

     GET filename

And execute with

     /
     

or, more commonly,load and and execute with

     @filename
Remember that this will look for files in the current directory. IF SQLPLUS cannot find the file, you may have started SQLPLUS from a different directory.

Creating tables

In a script defining a number of tables, start the script with

     DROP TABLE tabname;

statements, in an appropriate order so that foreign key integrity constraints are not violated (i.e. child before parent).

Access /Oracle SQL differences

There are a few differences between the two versions of SQL which should be noted: