Oracle表介紹--簇表
(column date_type [,column datatype]...)
[PCTUSED 40 | integer] [PCTFREE 10 | integer]
[SIZE integer]
[INITRANS 1 | integer] [MAXTRANS 255 | integer]
[TABLESPACE tablespace]
[STORAGE storage]
create cluster my_clu (deptno number )
pctused 60
pctfree 10
size 1024
tablespace users
storage (
initial 128 k
next 128 k
minextents 2
maxextents 20
);
3、建立簇表create table t1_dept(
deptno number ,
dname varchar2 ( 20 )
)
cluster my_clu(deptno);
create table t1_emp(
empno number ,
ename varchar2 ( 20 ),
birth_date date ,
deptno number
)
cluster my_clu(deptno);
4、為簇建立索引create index clu_index on cluster my_clu;
注:若不建立索引,則在插入資料時報錯:ORA-02032: clustered tables cannot be used before the cluster index is built 管理簇 使用ALTER修改簇屬性(必須擁有ALTER ANY CLUSTER的許可權)alter cluster my_clu
pctused 40
2、刪除簇 drop cluster my_clu; -- 僅適用於刪除空簇drop cluster my_clu including tables ; -- 刪除簇和簇表
drop cluster my_clu including tables cascade constraints ;
-- 同時刪除外來鍵約束
注:簇表可以像普通表一樣刪除。 雜湊聚簇表 在簇表中,Oracle使用儲存在索引中的鍵值來定位表中的行,而在雜湊聚簇表中,使用了雜湊函式代替了簇索引,先通過內部函式或者自定義的函式進行雜湊計算,然後再將計算得到的碼值用於定位表中的行。建立雜湊簇需要用到HASHKEYS子句。 1、建立雜湊簇create cluster my_clu_two(empno number(10) )
pctused 70
pctfree 10
tablespace users
hash is empno
hashkeys 150 ;
說明: * hash is 子句指明瞭進行雜湊的列,如果列是唯一的標示行,就可以將列指定為雜湊值 * hashkeys 指定和限制雜湊函式可以產生的唯一的雜湊值的數量 2、建立散列表create table t2_emp (
empno number ( 10 ),
ename varchar2 ( 20 ),
birth_date date ,
deptno number )
cluster my_clu_two(empno);
注意: * 必須設定數值的精度(具體原因不詳) * 雜湊簇不能也不用建立索引 * 雜湊簇不能ALTER:size、hashkeys、hash is引數轉自:http://www.blogjava.net/wxqxs/archive/2008/10/19/238636.html