📄 ch02.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Teach Yourself Oracle 8 In 21 Days -- Ch 2 -- Exploring the Oracle Architecture</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
<CENTER>
<H1><IMG SRC="../buttonart/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM" BORDER="0"><BR>
<FONT COLOR="#000077">Teach Yourself Oracle 8 In 21 Days</FONT></H1>
</CENTER>
<CENTER>
<P><A HREF="../ch01/ch01.htm"><IMG SRC="../buttonart/previous.gif" WIDTH="128" HEIGHT="28"
ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch03/ch03.htm"><IMG
SRC="../buttonart/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"
BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../buttonart/contents.gif" WIDTH="128"
HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A>
<HR>
</CENTER>
<CENTER>
<H1><FONT COLOR="#000077"><B>- Day 2 -</B></FONT></H1>
</CENTER>
<CENTER>
<H1><FONT COLOR="#000077">Exploring the Oracle Architecture</FONT></H1>
</CENTER>
<P><FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>The Oracle Relational Database
Management System, or <I>RDBMS</I>, is designed to allow simultaneous access to large
amounts of stored information. The RDBMS consists of the database (the information)
and the instance (the embodiment of the system). The database contains the physical
files that reside on the system and the logical pieces such as the database schema.
These database files take various forms, as described in the following section. The
instance is the method used to access the data and consists of processes and system
memory.
<BLOCKQUOTE>
<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>Object extensions have been added
to the RDBMS with Oracle8. The object extension to tables is covered in detail on
Day 12, "Working with Tables, Views, and Synonyms." Oracle refers to Oracle8
as an O-RDBMS (Object-Relational Database Management System). In this book, I refer
to Oracle as an RDBMS for clarity.
<HR>
</BLOCKQUOTE>
<H2><FONT COLOR="#000077"><B>The Database</B></FONT></H2>
<P>The Oracle database has a logical layer and a physical layer. The physical layer
consists of the files that reside on the disk; the components of the logical layer
map the data to these physical components.</P>
<H3><FONT COLOR="#000077"><B>The Physical Layer</B></FONT></H3>
<P>The physical layer of the database consists of three types of files:
<UL>
<LI>One or more datafiles--Datafiles store the information contained in the database.
You can have as few as one datafile or as many as hundreds of datafiles. The information
for a single table can span many datafiles or many tables can share a set of datafiles.
Spreading tablespaces over many datafiles can have a significant positive effect
on performance. The number of datafiles that can be configured is limited by the
Oracle parameter <TT>MAXDATAFILES</TT>.
<P>
<LI>Two or more redo log files--Redo log files hold information used for recovery
in the event of a system failure. Redo log files, known as the redo log, store a
log of all changes made to the database. This information is used in the event of
a system failure to reapply changes that have been made and committed but that might
not have been made to the datafiles. The redo log files must perform well and be
protected against hardware failures (through software or hardware fault tolerance).
If redo log information is lost, you cannot recover the system.
<P>
<LI>One or more control files--Control files contain information used to start an
instance, such as the location of datafiles and redo log files; Oracle needs this
information to start the database instance. Control files must be protected. Oracle
provides a mechanism for storing multiple copies of control files.
</UL>
<H3><FONT COLOR="#000077"><B>The Logical Layer</B></FONT></H3>
<P>The logical layer of the database consists of the following elements:
<UL>
<LI>One or more tablespaces.
</UL>
<UL>
<LI>The database schema, which consists of items such as tables, clusters, indexes,
views, stored procedures, database triggers, sequences, and so on.
</UL>
<H3><FONT COLOR="#000077"><B>Tablespaces and Datafiles</B></FONT></H3>
<P><FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>The database is divided into
one or more logical pieces known as <I>tablespaces</I>. A tablespace is used to logically
group data together. For example, you can create one tablespace for accounting and
a separate tablespace for purchasing. Segmenting groups into different tablespaces
simplifies the administration of these groups (see Figure 2.1). Tablespaces consist
of one or more datafiles. By using more than one datafile per tablespace, you can
spread data over many different disks to distribute the I/O load and improve performance.</P>
<P><A NAME="01"></A><A HREF="01.htm"><B>Figure 2.1.</B></A></P>
<P><I>The relationship between the database, tablespaces, and datafiles.</I></P>
<P>As part of the process of creating the database, Oracle automatically creates
the <TT>SYSTEM</TT> tablespace for you. Although a small database can fit within
the <TT>SYSTEM</TT> tablespace, it's recommended that you create a separate tablespace
for user data. The <TT>SYSTEM</TT> tablespace is where the data dictionary is kept.
The data dictionary contains information about tables, indexes, clusters, and so
on.</P>
<P>Datafiles can be operating system files or, in the case of some operating systems,
RAW devices. Datafiles and data access methods are described in detail on Day 12.</P>
<H3><FONT COLOR="#000077"><B>The Database Schema</B></FONT></H3>
<P><FONT COLOR="#000077"><B>New Term:</B></FONT><B> </B>The database schema is a
collection of logical-structure objects, known as <I>schema objects</I>, that define
how you see the database's data. These schema objects consist of structures such
as tables, clusters, indexes, views, stored procedures, database triggers, and sequences.
<UL>
<LI>Table--A table, which consists of a tablename and rows and columns of data, is
the basic logical storage unit in the Oracle database. Columns are defined by name
and data type. A table is stored within a tablespace; often, many tables share a
tablespace.
<P>
<LI>Cluster--A cluster is a set of tables physically stored together as one table
that shares a common column. If data in two or more tables is frequently retrieved
together based on data in the common column, using a clustered table can be quite
efficient. Tables can be accessed separately even though they are part of a clustered
table. Because of the structure of the cluster, related data requires much less I/O
overhead if accessed simultaneously.
<P>
<LI>Index--An index is a structure created to help retrieve data more quickly and
efficiently (just as the index in this book allows you to find a particular section
more quickly). An index is declared on a column or set of columns. Access to the
table based on the value of the indexed column(s) (as in a <TT>WHERE</TT> clause)
will use the index to locate the table data.
</UL>
<BLOCKQUOTE>
<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>A new feature in Oracle8 is the
index-only table. In an index-only table, the data and index are stored together.
This is discussed in detail on Day 13, "Using Indexes and Sequences."
<HR>
</BLOCKQUOTE>
<UL>
<LI>View--A view is a window into one or more tables. A view does not store any data;
it presents table data. A view can be queried, updated, and deleted as a table without
restriction. Views are typically used to simplify the user's perception of data access
by providing limited information from one table, or a set of information from several
tables transparently. Views can also be used to prevent some data from being accessed
by the user or to create a join from multiple tables.
<P>
<LI>Stored procedure--A stored procedure is a predefined SQL query that is stored
in the data dictionary. Stored procedures are designed to allow more efficient queries.
Using stored procedures, you can reduce the amount of information that must be passed
to the RDBMS and thus reduce network traffic and improve performance.
<P>
<LI>Database trigger--A database trigger is a procedure that is run automatically
when an event occurs. This procedure, which is defined by the administrator or developer,
triggers, or is run whenever this event occurs. This procedure could be an insert,
a deletion, or even a selection of data from a table.
<P>
<LI>Sequence--The Oracle sequence generator is used to automatically generate a unique
sequence of numbers in cache. By using the sequence generator you can avoid the steps
necessary to create this sequence on your own such as locking the record that has
the last value of the sequence, generating a new value, and then unlocking the record.
</UL>
<H3><FONT COLOR="#000077"><B>Segments, Extents, and Data Blocks</B></FONT></H3>
<P>Within Oracle, the space used to store data is controlled by the use of logical
structures. These structures consist of the following:
<UL>
<LI>Data blocks--A block is the smallest unit of storage in an Oracle database. The
database block contains header information concerning the block itself as well as
the data.
<P>
<LI>Extents--Extents consist of data blocks.
<P>
<LI>Segments--A segment is a set of extents used to store a particular type of data,
as shown in Figure 2.2.
</UL>
<P><A NAME="02"></A><A HREF="02.htm"><B>Figure 2.2.</B></A></P>
<P><I>Segments, extents, and data blocks.</I></P>
<P><FONT COLOR="#000077"><B>Segments</B></FONT></P>
<P>An Oracle database can use four types of segments:
<UL>
<LI>Data segment--Stores user data within the database.
<P>
<LI>Index segment--Stores indexes.
<P>
<LI>Rollback segment--Stores rollback information used when data must be rolled back.
<P>
<LI>Temporary segment--Created when a SQL statement needs a temporary work area;
these segments are destroyed when the SQL statement is finished. These segments are
used during various database operations, such as sorts.
</UL>
<P><FONT COLOR="#000077"><B>Extents</B></FONT></P>
<P>Extents are the building blocks of segments; in turn, they consist of data blocks.
An extent is used to minimize the amount of wasted (empty) storage. As more and more
data is entered into tablespaces in your database, the extents used to store that
data can grow or shrink as necessary. In this manner, many tablespaces can share
the same storage space without preallocating the divisions between those tablespaces.</P>
<P>At tablespace-creation time, you can specify the minimum number of extents to
allocate as well as the number of extents to add at a time when that allocation has
been used. This arrangement gives you efficient control over the space used in your
database.</P>
<P><FONT COLOR="#000077"><B>Data Blocks</B></FONT></P>
<P>Data blocks are the smallest pieces of an Oracle database; they are physically
stored on disk. Although the data block in most systems is 2KB (2,048 bytes), you
can change this size for efficiency depending on your application or operating system.
<BLOCKQUOTE>
<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>Oracle blocks do not need to be,
and may not be the same as, operating system data blocks. In fact, in most cases
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -