Académique Documents
Professionnel Documents
Culture Documents
EXERCISE 1 & 2
Stefan Lederer | 0761467
Exercise 1 - Physical
Structure
Explain the Oracle-concepts segment, extent, block.
Interpret the following statement:
A cluster of tables
Sub-queries
Rollback-Segments
The undo is stored in rollback segments.
create table test ( a number (8), s varchar2 (1000)
) tablespace USERS
storage (
initial 1M
next 100K
minextents 1
maxextents 100
pctincrease 50
);
Table is created in tablespace USERS
Initial Extend has the size 1 M
2nd Extend has 100 K
3rd Extend has 150 K …
Minimum 1 Extend is created
Maximum 100 Extends are allowed
Excercise 2 – Table Analysis
create_part.sql
Create Table PART with 20 000 Entries
Table Analyze
ANALYZE TABLE part COMPUTE
STATISTICS;
OR
EXEC
DBMS_STATS.GATHER_TABLE_STATS(‘db
t_yxx’, ‘part’);
Why Analyze a Table?
It is used by the CBO (Cost Based
Optimizer)
…number of rows in this
table
Select num_rows from user_tables where
table_name = ‚PART‘;
…average size of a record.
Select avg_row_len from user_tables
where table_name = ‚PART‘;
…number of distinct values for
each column
Select num_distinct, column_name from
user_tab_columns where table_name =
‚PART‘;
…the density of each
column
Select density, column_name from
user_tab_columns wehre table_name
=‚PART‘;
by the way: what is the
density?
Density is a column statistic and provides selectivity
estimates for
equi-join predicates (e.g. and A.COL1 = B.COL1) and
equality predicates (e.g. COL1 = 5).