Vous êtes sur la page 1sur 19

DATA DICTIONARY

DATA DICTIONARY
USER TABLES
DATA DICTIONARY : create and maintained by
oracle server. Contains information about the
database. It is structured in tables and views. .
It is central to every oracle database. Data
dictionary is read only. You can issue queries
against its tables and views only.
What info can be found by the data
dictionary
Definitions of all schema objects in the
database( like tables, views, indexes,functions
etc)
Default values for columns
Integrity constraints information
Names of oracle users
Privileges and roles each user has been given
Other general database information
Data dictionary structure
Base tables: store information about associated
databases. Only oracle server should write to and
read from these tables.
User-accessible views: There are several views
that summarize and display the info stored in the
base tables. These views help us see base table
information using joins and where conditions.
Most users have access to views rather than base
tables
SYS owns all the base tables and user-accessible
views on data dictionary
There are three views:
They have similar information
Distinguishable from each other by their prefixes.
Exp:
USER_OBJECTS (contains info about the objects that you
own or you created)
ALL_OBJECTS(contains info about the objects to which you
have access)
DBA_OBJECTS(contains info about all the objects that are
owned by all users)
The three views have similar information about the objects
in the database but the scope is different.
Set of views prefixed with v$: these are
dynamic in nature and hold information about
performance.
These tables should not be accessed by most
users.
Using dictionary views
DESCRIBE DICTIONARY
It contains the name and descriptions of the
dictionary tables and views.
SELECT * FROM DICTIONARY WHERE
TABLE_NAME = USER_OBJECTS;
We can search information about a particular view
We can also search the comments column for a
particular word or phrase.
SELECT TABLE_NAME FROM DICTIONARY WHERE
LOWER(COMMENTS) LIKE %COLUMNS%;
Query user_objects to see all the objects that
you own
Query all_objects to see all Objects you have
access to.
User_objects view
Select object_name, object_type, created,
status from user_objects ORDER BY
object_type;
Getting Table info
DESCRIBE user_tables;
Select table_name from user_tables;
User_table view can be used to obtain the name
of all your tables.
It contains info about the storage
Tabs view is a synonym of user_table
Select table_name from tabs;
Column information
USER_TAB_COLUMNS
Describe user_tab_columns;
It will provide you with the detailed information about
columns in your tables
This view contains information about:
Column names
Column datatypes
Length of datatypes
Precision and scale of number columns
Default value
Is there a not null constraint
SELECT column_name,data_type, data_length,
data_precision, data_scale, nullable FROM
user_tab_columns WHERE table_name=
EMPLOYEES;
CONSTRAINT INFO
USER_CONSTRAINTS describes the constraint
definitions on your table
USER_CONS_COLUMNS describes columns
that are owned by you and that are specified
in constraints
Select constraint_name, constraint_type, search_condition,
r_constraint_name, delete_rule, status FROM
user_constraints WHERE table_name= EMPLOYEES;
The constraint type can be:
C (check or not null)
P(primary key)
U(unique key)
R(referential integrity)
V(with check option on a view)
O(with read only option, on a view)
The DELETE RULE:
CASCADE:if parent record is deleted, child record is also deleted
SET NULL: if parent record is deleted, set child record to null
NO ACTION: a parent record can be deleted if no child record
exists.
STATUS can be:
ENABLED: Constraint is active
DISABLED: Constraint is made not active
Querying user_cons_columns
Describe user_cons_columns
Select constraint_name, column_name from
user_cons_columns where table_name=
EMPLOYEES;
Adding comment to a table
Comment on table employees is this is the
information;
Comment on column employees.first_name is this is
the first name;
Comments can be viewed trough data dictionary views:
ALL_COL_COMENTS
USER_COL_COMMENTS
ALL_TAB_COMMENTS
USER_TAB_COMMENTS
COMMENT CAN BE DROPPED BY SETTING IT TO EMPTY
STRING

Vous aimerez peut-être aussi