Structured Query Language (SQL)
- a module of Oracle Database Management System
A. GETTING INTO SQL:
1. Sign onto oz with your regular account /password combo
2. % telnet rabbit [this will call up another Unix machine]
New account/passwords have been established for MIS students
These will be given out in class and are of the format orabu00.
4. Sign into rabbit using your rabbit account.
5. At the new prompt, type "sqlplus" [don't type the quotes]
SQL accounts have also been set up for every MIS student.
They are similar to, but different from, your rabbit account
and will also be given out in class.
6. I'd suggest that you try the exercise below first, then
set up your spool file, and then do the exercise a second time.
7. Ezprint is not available in rabbit, so you'll have to
map your network drive to rabbit in order to move your file
from rabbit into oz.
7a. To map network drive to rabbit: right click "My Computer",
left click "Map Network Drive". Path= \\rabbit\orabu00 [or
whatever]. password = your rabbit password.
7b. To move your .lst file from rabbit to oz, right click
"My Computer", "Explore", right click your rabbit drive
(found in the listing), "explore" the rabbit drive. Find
your .lst file (the spool file). Use a right button drag to
copy it to your oz drive.
7b(option) You could leave your .lst file in rabbit, and use
MSWord to edit/print the file. When you "open" the file, look
for your "rabbit drive". The file type is "all files" and
should be readable/editable/printable in MSWord.
B. SOME USEFUL SQL COMMANDS INCLUDE:
SQL> help [runs "help"]
SQL> edit [runs editor (e.g. pico) to edit last command]
SQL> l [list last command]
SQL> r [runs last command]
SQL> desc tablename [displays schema of table]
SQL> quit [gets you back to system level]
C. THE SQL EXERCISE: Due Thursday 4 Nov 99 by midnight
1) Create a table of your choice (don't use "junk"). Use a
business application (customers, sales, employees, etc) or a
personal application (cars, flowers, pets, friends, movie stars, etc.)
Include a numeric field, character field & date field
Example:
SQL> create table junk
2 (junkno number (3) not null,
3 junkname char(10),
4 junkdate date);
2) Put data into your table:
SQL> insert into junk
2 values (001,'trash','30-oct-97');
3) Perform a query on the demo tables:
SQL> select lname
2 from uspres
3 where yrdied<(yrinaug+4)
4 and yrdied>0;
4) Edit/Print sql session:
SQL> spool filename [this creates a "spool" file into which all
subsequent work will be recorded]
5) SQL> Do exercise steps 1),2),3) a second time. [Note: If you try
to create a table with the same name as one that you had previously
created, you will get an error] All inputs / outputs made by the user
or the computer will be saved into a Unix level spool file (not an SQL
table). Spool files will AUTOMATICALLY by given the extension ".lst".
6) SQL> quit [this closes the "spool" file & returns you to system level]
7) Map the network drive, use MSWord to open, edit (clean up any errors, and
add your name and date to the top of the page) and print.
8) The exercise is completed when a hard copy of the edited spool file is
turned in to me.