Oracle 8i User Guide For CS2312: SQL Plus User's Guide and Reference Manual Available On The Web
Oracle 8i User Guide For CS2312: SQL Plus User's Guide and Reference Manual Available On The Web
1. Introduction
Oracle is a relational database management system that uses SQL as its data
manipulation language. Information on SQL is given separately to these notes. These
notes are a fast-start to the way we will use Oracle in the labs and supplement the
SQL*Plus User's Guide and Reference manual available on the web.
The Oracle database resides on a server. This is where the binaries are and your
databases. Your database tables DO NOT reside in your own file store and can only be
accessed by using an Oracle tool. When you log onto a machine and start an Oracle tool
the server must be notified to serve the tool to your machine. This can be slow.
However, once the tool is loaded onto the client it runs the program locally so this is
faster. Once you have started a tool don't close it down unless you are finished.
You will be developing your database implementations in pairs. To avoid confusion and
wasted disk space do not create multiple tables with the same things in them. There
should only be one team database, looked after by one person and the other should be
granted permission to use that database (see later on how to do that).
2. Oracle
2.1 Oracle Architecture
Oracle, very simplistically, can be viewed as having a nested architecture (figure 1)
SQL*Net
PL/SQL
Utilities Cartridges
1
2
Describes in detail the Oracle objects. It is used for documentation and management of
the objects. Holds the schema of the tables and views. The description of database
objects is often called metadata (data about data). The dictionary is a set of tables and
views manipulated through SQL. Users can look at the content of the tables through a
series of views. Only the DBA can actually manipulate the dictionary directly (see
figure 2).
Significant
View Users
contents
View can look at these
View
Table
Coded
Table DBA
contents
can manipulate these
Table Table
Description of
objects in the
database
2
3
Tables
Views
Integrity constraints
Users and their privileges
Accelerators on tables (indexes, clusters) -- these are data structures which give a
fast access path to tables, a bit like an index in a book. See Chapters 4 & 5 of
Elmasri and Navathe. We will cover these later in the course.
In Oracle, a user cannot explicitly define an object called a database; a users database is
the set of tables and views that a user has access privileges to. A user may access table
and views other than those created by themselves by prefixing them with the name of
that user, provided they have been granted the privilege of doing so.
Cluster Index
In Figure 3, user1 has created two tables, table1 and table2, and a view view1. The two
tables are grouped in the same cluster, which means that they are stored internally close
together on the disk because they are often accessed together. This same user can access
table table3 via view view2. User3 has created a table table3, which uses an index (a
data structure which makes accessing data in it faster), and two views view2 and view3
on this table. Finally user2 has created no table or view, but has the privilege of
accessing table table2 by prefixing it with the name of user1.
Database
Tablespace staff
Tablespace project
Tablespace system
Tablespace cags_course
Tablespace msc
Figure 4: Tablespaces
4
5
Sometimes SQL commands refer to the user name of an Oracle user. Usually your user
name will be the same as the Unix one.
SQL commands:
the commands for controlling, defining, manipulating and querying the database
tables. The SQL Language Reference Manual is the complete manual of the
whole of the Oracle SQL language. The SQL language is used for creating,
manipulating, updating, querying and deleting your tables and the data
dictionary tables. It is very useful and is available on the web. For CS2311 you
can ignore any statement that has the following keywords when referring to the
manual: Rollback, Databases, Tablespaces, Storage and blocks, Clusters and
indexes, Distributed.
SQL*Plus commands:
additional commands governing the SQL*Plus environment, formatting or
results and measuring performance. The complete manual is on the web. I have
included in these notes the basics with a page number of the Guide for further
details. When reading this Guide ignore any reference to PL/SQL and
SQL*Forms.
Oracle is not case-sensitive, which means you can use upper or lower case for
commands, names of tables and so on, but Oracle wont tell any difference between
STUDENT, Student or student.
6. Backing Up
We do keep a backup. However, for an immediate fix if you muck up a relation is to use
a SQL batch file to create tables, and a SQL batch file for loading the tuples. Then keep
these files in a safe place in the teams collective file store. Then, if all goes wrong you
can rebuild from scratch. Otherwise you will have to ask the DBA to restore your table
which is rather difficult.
To compress these files so they use up less of your filestore quota, look at the Unix
commands compress and uncompress.
5
6
is held as tables so the usual SQL commands work. Appendix B of the Oracle8 Server
Administrators Guide has a list of all the Data Dictionary Views and the Oracle
reserved words. The most interesting Data Dictionary Views for you are: