Introduction to the Data Dictionary
Introduction to the Data Dictionary
One of the most important parts of an Oracle database is its data dictionary, which
is a read-only set of tables that provides information about the database. A data
dictionary contains:
_ The definitions of all schema objects in the database (tables, views, indexes,
clusters, synonyms, sequences, procedures, functions, packages, triggers,
and so on)
_ How much space has been allocated for, and is currently used by, the
schema objects
_ Default values for columns
_ Integrity constraint information
_ The names of Oracle users
_ Privileges and roles each user has been granted
_ Auditing information, such as who has accessed or updated various
schema objects
_ Other general database information
The data dictionary is structured in tables and views, just like other database data.
All the data dictionary tables and views for a given database are stored in that
database’s SYSTEM tablespace.
Not only is the data dictionary central to every Oracle database, it is an important
tool for all users, from end users to application designers and database
administrators. Use SQL statements to access the data dictionary. Because the data
dictionary is read-only, you can issue only queries (SELECT statements) against it’s tables
and views.
Structure of the Data Dictionary
The data dictionary consists of the following:
Base Tables
The underlying tables that store information about the associated database. Only
Oracle should write to and read these tables. Users rarely access them directly
because they are normalized, andmost of the data is stored in a cryptic format.
User-Accessible Views
The views that summarize and display the information stored in the base tables of
the data dictionary. These views decode the base table data into useful information,
such as user or table names, using joins and WHERE clauses to simplify the
information. Most users are given access to the views rather than the base tables.
SYS, Owner of the Data Dictionary
The Oracle user SYS owns all base tables and user-accessible views of the data
dictionary. No Oracle user should ever alter (UPDATE, DELETE, or INSERT) any rows or
schema objects contained in the SYS schema, because such activity can compromise data
integrity. The security administrator must keep strict control of this central account.
or downgraded.
During database operation, Oracle reads the data dictionary to ascertain that
schema objects exist and that users have proper access to them. Oracle also updates
the data dictionary continuously to reflect changes in database structures, auditing,
grants, and data.
For example, if user Kathy creates a table named parts, then newrows are added
to the data dictionary that reflect the new table, columns, segment, extents, and the
privileges that Kathy has on the table. This new information is then visible the next
time the dictionary views are queried.
Public Synonyms for Data Dictionary Views
Oracle creates public synonyms for many data dictionary views so users can access
them conveniently. The security administrator can also create additional public
synonyms for schema objects that are used systemwide. Users should avoid naming
their own schema objects with the same names as those used for public synonyms.
Cache the Data Dictionary for Fast Access
Much of the data dictionary information is kept in the SGA in the dictionary cache,
because Oracle constantly accesses the data dictionary during database operation to
validate user access and to verify the state of schema objects. All information is
stored in memory using the least recently used (LRU) algorithm.
Parsing information is typically kept in the caches. The COMMENTS columns
describing the tables and their columns are not cached unless they are accessed
frequently.
Other Programs and the Data Dictionary
Other Oracle products can reference existing views and create additional data
dictionary tables or views of their own. Application developers who write
programs that refer to the data dictionary should refer to the public synonyms
rather than the underlying tables: the synonyms are less likely to change between
software releases.
How to Use the Data Dictionary
The views of the data dictionary serve as a reference for all database users. Access
the data dictionary views with SQL statements. Some views are accessible to all
Oracle users, and others are intended for database administrators only.
The data dictionary is always available when the database is open. It resides in the
SYSTEM tablespace, which is always online.
The data dictionary consists of sets of views. In many cases, a set consists of three
views containing similar information and distinguished from each other by their
prefixes: