ITPub博客

首页 > 数据库 > Oracle > 数据库表--sorted hash clustered table

数据库表--sorted hash clustered table

原创 Oracle 作者:jelephant 时间:2013-12-09 11:53:14 0 删除 编辑
有序散列聚簇表(sorted hash clustered table)是10g之后新增。结合了散列聚簇和IOT的特性。如果经常使用如下查询,则很适合使用有序散列聚簇表。Select * From t Where KEY=:x Order by SORTED_COLUMN。通过使用有序散列聚簇,Oracle可以返回数据而不用执行排序。这是通过插入时按键有序物理存储数据做到的。

创建散列聚簇表的步骤:
创建散列聚簇
create cluster order_cluster (  
  cust_id number, order_date timestamp sort)  
  hashkeys 1000 size 512 hash is cust_id;
这个散列聚簇中的数据将按CUST_ID查找(查找条件是 CUST_ID = :X),按ORDER_DATE物理排序。

创建表格
create table cust_orders (  
  cust_id number,  
  order_date timestamp sort,  
  oerder_number number,  
  description varchar2(100))  
  cluster order_cluster(cust_id, order_date);

使用有序散列聚簇表时,应当考虑到散列聚簇同样的问题,另外还要考虑到一个约束条件,即数据应该按键值的有序顺序到达。如果信息随机地到达(不按有序的顺序到来),插入过程中必须移动大量的数据使得这些行在磁盘上物理有序。在这种情况下,不建议采用有序散列聚簇(此时采用IOT可能很合适)。

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

请登录后发表评论 登录
全部评论

注册时间:2013-12-07

  • 博文量
    143
  • 访问量
    681871