Physical Design: Examples

advertisement
Physical Design: Oracle Examples
ITM354, Dr. Chen
1. create table Employee
(EmpNo number(10) Primary Key,
Name
Varchar2(40) Not null,
DeptNo Number (2) Default 10,
Salary
Number(7,2) Check (Salary<1000000),
Birthdate Date,
SSN
Char(9) Unique,
Foreign key (deptno) refernces Dept(Dno))
tablespaces USERS;
2. create tablespace Codes_tables
datafile ' /u01/racle/VLDB/codes_tables.dbf''
size 10M
extent management local uniform size 256K;

default is 1MB)
 assuming the block size is 4KB, the blocking factor will be 256/4 = 64.
 Note that: you cannot change the blocksize after the database creation. You
declare the block size in the init.ora file before database creation:
DB_BLOCK_SIZE=4K.
3. alter index IU_spaces$DB_TS_CD rebuild
storage (initial 16M next 16M pctincreates 0)
tablespace INDX_1;
4. Materialized View
a. datawarehousing (summarization, precomuted data, etc.)
b. distributed database (replication)
c. speed up performance for queries involving aggregates or join
CREATE MATERIALIZED VIEW Store_dept_sal_mv
PCTFREE 0 TABLESPACE Mviews
STORAGE (initial 1M next 1M pctincrease 0)
BUILD deferred
REFRESH complete
ENABLE QUERY REWRITE
AS
select d.Dname, sum (salary) as tot_sum
from department d, employee e
where d.dnum = e.dno
group by d.dname;
SQL3 standards:
5. CREATE INDEX Rating ON Student
WITH STRUCTURE = BTREE,
KEY = (age, gpa)
Download