【实验】【聚簇】聚簇(Cluster)和聚簇表(Cluster Table)的创建与总结

【实验优先】演示标准创建和删除过程
1.创建聚簇
sec@ora10g> create cluster cluster_test(id int);

Cluster created.

2.创建聚簇表
sec@ora10g> create table tab_cluster1(id int primary key, name1 varchar2(30)) cluster cluster_test(id);

Table created.

sec@ora10g> create table tab_cluster2(id int primary key, name2 varchar2(30)) cluster cluster_test(id);

Table created.

3.创建聚簇索引
sec@ora10g> create index idx_cluster_test on cluster cluster_test;

Index created.

4.删除聚簇
sec@ora10g> drop cluster cluster_test including tables;

Cluster dropped.

5.查看聚簇表所属的聚簇
sec@ora10g> select owner,table_name,cluster_name from dba_tables where wner='SEC' and table_name in ('TAB_CLUSTER1','TAB_CLUSTER2');

OWNER          TABLE_NAME          CLUSTER_NAME
-------------- ------------------- ---------------
SEC            TAB_CLUSTER2        CLUSTER_TEST
SEC            TAB_CLUSTER1        CLUSTER_TEST

【总结ing】
聚簇(Cluster)和聚簇表(Clustered Table)的优点:
1.表中的数据一起存储在簇中,连接这些表的查询就可能执行更少的I/O,改善系统性能
2.对于经常一同查询的表可以明显的加速表的连接(Join)
3.非常适合查询频繁的环境

聚簇(Cluster)和聚簇表(Clustered Table)的缺点:
1.因为是一类比较特殊的对象,所以增加了数据库的管理负担
2.非常不适合更改频繁的环境
3.如果聚簇表总是在一起查询,考虑是否可以将他们合并为一个表

聚簇(Cluster)和聚簇表(Clustered Table)的特点:
1.聚簇由多个表组成
2.几个表共享相同的数据块
3.一个聚簇有一个或者多个公共的列,多个表共享这些列,这样的列叫做:聚簇关键字或簇键(Cluster Key)
4.Oracle把多个表的数据物理地存储在一起

【BTW】
聚簇表中插入数据之前,聚簇上需先有聚簇索引。否则会出现如下的错误:
sec@ora10g> select * from tab_cluster1;
select * from tab_cluster1
              *
ERROR at line 1:
ORA-02032: clustered tables cannot be used before the cluster index is built

-- The End --

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/519536/viewspace-610869/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/519536/viewspace-610869/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值