12.Data Dictionary
12.Data Dictionary
• SYS.TAB$
– Contains administrative information about tables
• There are many additional system tables in
the Oracle data dictionary
Using Comments to Describe
Database Objects
• COMMENT ON statement
– Can put comments on each database object as a
general description of that object
– comment on
table orders
is ‘Contains all unfilled orders’;
– comment on
column orders.dollars
is ‘Total value =
qty*products.price’;
Using Comments to Describe
Database Objects
• select comment$ from sys.com$
where col# is null
and obj# in
(select obj# from sys.obj$
where name = ‘orders’);
• The DD contains a lot of information we may not
want to be generally available
• Possible to create views such that users can see
data related only to tables created by themselves
• Tables owned by sys (the DBA) are not generally
available to ordinary users
Sample Queries on the DD
• Can a particular user create a table with a particular
name, or has s/he already used that name?
• Which views are based on more than one base
table?
• Finally, one to show you we have not covered
everything there is to know ...
– How much storage space is still free in the entire
database?
– select sum(f.length*ts.blocksize)
from sys.ts$ ts, sys.fet$ f
where ts.ts# = f.ts#;
grant statement
connect, dba, resource
• Several versions of grant statement
• connect: allows new users to have access to Oracle
• grant connect to jeff
identified by pwxx4r;
• resource: allows users to create their own tables
with all privileges (see later) on those tables
• grant resource to veda, greenthing;
/* Assumes veda and greenthing exist
• dba: execute all commands on all database objects
• grant dba to mom, dick, mary
identified by dad, ehsg, plymouth;
grant Statement
Table Privileges
• Allows “owner” of a table to control access by other
database users to data in the tables
• Types of access include
– select: allows users to select from specified
table
– insert, delete, update, index, alter
– references: allows user to define foreign keys
on specified table
– all: allows user all privileges specified above
• with grant option clause allows recipient to
pass the privilege on
grant Statement
Table Privileges
• grant insert on orders to paul
with grant option;
• grant insert, delete, update
on customers to marilyn;
• grant update (quantity)
on products
to anil;
• grant select on agents to public;
/* Provides every user the
privilege */
grant and revoke
Statements
• All table privileges are stored in a table called
TABAUTH$ with primary key SEQUENCE#
• Update privileges on columns are stored in
COLAUTH$
• revoke statement withdraws privileges previously
granted (connect, dba, resource, table privileges)
• revoke dba from dick;
• revoke resource from greenthing;
• revoke delete on customers from
marilyn;
• revoke select on agents from public;