University of Helsinki
Database Management, Practice Session 1, Spring 2003
Oracles's dictionary table user_tables gives information about tables.
Table user_tab_columns
list the columns. The following query retrieves column information for all users' tables.
select t.table_name, column_name, data_type, data_length,
nullable, column_id
from user_tables t, user_tab_columns c
where t.table_name=c.table_name
order by c.table_name, column_id
JDBC API provides the class DatabaseMetaData for metadata.
The method getMetaData() of class Connection retrieves the metadata associated to the
current connection. To get the tablenames DatabaseMetaData provides the method getTables(String catalog,
String schemaPattern, String tableNamePattern,
String [] types). The pattrers are masks uses in mapping strings with SQL's like operation.
The tables of owner SCOTT are retrieved with method call getTables(null,"SCOTT","%",{"TABLE"}).
getTables produces a ResultSet object as its return value. Each row of the result
contain the columns TABLE_CAT, TABLE_SCHEM, TABLE_NAME, TABLE_TYPE and REMARKS.
Method getColumns gives information about columns. In this case the resulting rows
contain columns COLUMN_NAME and TYPE_NAME Petri Helin has mase a
test program,
to apply these metrhods. This program builds the create table definitions for Scott's tables.
Oracle's table user_constraint contains information about integrity constraints.
If the constraint is foreign key constraint, the type of the constraint is 'R'.
Two rows of table user_constraints are needed in representing a foreign key: one for the origin
and one for the target. Column r_constraint_name in the origin row identifies the constraint.
The columns that belong to the foreign key are defined in table user_cons_columns. The following query contains an
example of how to use these tables.
select c.constraint_name, c.table_name, r.table_name
referenced_table, cc.position, cc.column_name, c.delete_rule
from user_constraints c, user_constraints r, user_cons_columns cc
where c.constraint_type='R' and
c.status='ENABLED' and c.r_constraint_name=r.constraint_name
and c.constraint_name=cc.constraint_name
order by c.constraint_name, c.table_name, cc.position
The size of a disk block is 1KB. Each track stores 500 blocks. The rotation speed is 3600 rpm. The average seek time is 12 ms.
The capacity of a cylinder = track capacity * number of tracks in cylinder = 500*1KB*20= 10MB
Block access time = seek time + rotation delay + transfer time =
12ms + 1/2*1/60 s + 1/500*1/60s=
12ms+1/120 s+1/30000s=
12ms+8.3ms+0.03 ms=20.33ms