Table Cluster Index-organized Table ---------- Ordering of Rows ---------> Random Grouped Ordered
ORD_NO PROD QTY ... ----- ------ ------ 101 A4102 20 102 A2091 11 102 G7830 20 102 N9587 26 101 A5675 19 101 W0824 10
ORD_NO ORD_DT CUST_CD ------ ------ ------ 101 05-JAN-97 R01 102 07-JAN-97 N45
Cluster Key
(ORD_NO)
101 ORD_DT CUST_CD
05-JAN-97 R01
PROD QTY
A4102 20
A5675 19
W0824 10
102 ORD_DT CUST_CD
07-JAN-97 N45
PROD QTY
A2091 11
G7830 20
N9587 26
CREATE CLUSTER scott.ord_clu (ord_no NUMBER(3)) SIZE 200 TABLESPACE DATA01 STORAGE(INITIAL 5M NEXT 5M PCTINCREASE 0) ;2. Cluster-Index erstellen.
CREATE INDEX scott.ord_clu_idx ON CLUSTER scott.ord_clu TABLESPACE INDX01 STORAGE(INITIAL 1M NEXT 1M PCTINCREASE 0) ;3. Tabellen im Cluster erstellen.
CREATE TABLE scott.ord
(
ord_no NUMBER(3)
CONSTRAINT ord_pk PRIMARY KEY,
ord_dt DATE, cust_cd VARCHAR2(3)
)
CLUSTER scott.ord_clu(ord_no)
;
CREATE TABLE scott.item
(
ord_no NUMBER(3)
CONSTRAINT item_ord_fk REFERENCES scott.ord,
prod VARCHAR2(5),
qty NUMBER(3),
CONSTRAINT item_pk PRIMARY KEY(ord_no,prod)
)
CLUSTER scott.ord_clu(ord_no)
;
CREATE CLUSTER scott.off_clu ( country VARCHAR2(2),postcode VARCHAR2(8) ) SIZE 500 HASHKEYS 1000 TABLESPACE DATA01 STORAGE(INITIAL 5M NEXT 5M PCTINCREASE 0);2. Tabellen im Cluster erstellen.
CREATE TABLE scott.office ( office_cd NUMBER(3), cost_ctr NUMBER(3), country VARCHAR2(2), postcode VARCHAR2(8) ) CLUSTER scott.off_clu(country,postcode) ;
DROP CLUSTER scott.ord_clu INCLUDING TABLES;Oder lösche die Tabellen vor dem Cluster.
DROP TABLE scott.ord; DROP TABLE scott.item; DROP CLUSTER scott.ord_clu;
Accessing index-organized table:
Non-key columns
Key column
Row header
CREATE TABLE scott.sales ( office_cd NUMBER(3), qtr_end DATE, revenue NUMBER(10,2), review VARCHAR2(1000), CONSTRAINT sales_pk PRIMARY KEY(office_code, qtr_end) ) ORGANIZATION INDEX TABLESPACE data01 PCTTHRESHOLD 20 OVERFLOW TABLESPACE data02 ;
Stefan Hietel dama.go GmbH, Robert Warnke http://rowa.giso.de