Basic Stuff
ORACLE 8i is installed in the undergraduate lab in McBryde
Hall (Room 118). To use it, you first need an account on the lab machines.
Please contact the lab administrator for details. In addition to the regular
account, you need a "database" account that you will use to connect to the
ORACLE database server. We have already created these accounts for you. These
accounts have names like "user1", "user2" etc. The passwords will be handed
out in class. You cannot change the account name,
but the passwords *should be* changed. So, as soon as you receive the account
information, login to change the initial password (instructions follow below).
Open ORACLE8i on a Win2000 Machine
Oracle 8i is installed on each Win2000 machine in
the CS lab in McB 118. To open Oracle, log on to your account. Choose
"Start" -> "Programs" -> "Course Software" -> "Oracle 8i"
-> "SQL Plus". When you enter "SQL Plus", you will see a dialog box.
Enter your groupname as "User Name" (user1, user2 etc.), password as
"Password", and "cs4604" as "Host String". Then, the system will force you
to change the password.
If you still need to change the password later, you can use the
following command.
alter user "user1" identified by "hello";
The command as above changes the password for user "user1" to
"hello".
Oracle Documentation
You can access the Oracle Documentation online.
Just click
http://www.csee.umbc.edu/help/oracle8/server.815/index.htm, and then select
Oracle8i SQL Reference. Notice that this manual is for a slightly
older version of ORACLE, but it shouldn't matter. Using SQLPlus
CREATE TABLE STUDENT
( |
SSN |
NUMBER(9) |
NOT NULL PRIMARY KEY, |
NAME |
VARCHAR2(50) |
NOT NULL, |
GENDER |
CHAR(1), |
|
DEPARTMENT |
VARCHAR2(25) |
|
); |
- Insert rows into a table:
INSERT INTO STUDENT
VALUES( |
123456789, 'CHRISTINA', 'F',
'MARKETING' |
); |
SELECT * FROM
STUDENT; |
SELECT * FROM STUDENT WHERE GENDER
= 'F'; |
Exiting SQLPlus
Type "quit;" at the prompt.
Recording your Session
Use the "spool" command within sqlplus.
At the SQL> prompt, type: spool foo;
and a file called foo.lst will
appear in your current directory and will hold everything typed, until you exit
sqlplus or type: spool off;
Using the Bulk Loader in ORACLE
The ORACLE SQL* Loader is a facility
that allows you to populate database tables from flat files. To use this
facility, you need to prepare (i) your flat file(s) (containing data), and (ii)
a control file that tells ORACLE how to "map" fields of the flat file to columns
of an RDBMS table. Furthermore, the data can also be appended at the end of the
control file, making the process much simpler. Most probably, you will prepare
one control file for each table that you want to bulk load to. Notice that
preparing the data is part of your assignment. There are no "tools" for this.
You either create them from some C program (example) that generates the data and
outputs it into a file, or if you are lucky, you might find a web page that
already has the data that you need with minimal text processing.
Here are
some hints and steps to help in bulk loading.
- Preparing the Control File: You can create one using a text editor
such as notepad and then save it with a ".ctl" extension. You can click
http://www.csee.umbc.edu/help/oracle8/server.815/a67792/toc.htm, and the