Table

1、如何创建cluster table?

SQL> show user
USER is "HR"
SQL> create cluster dept_emp_cluster(department_id number(4));

Cluster created.

SQL> create index idx_dept_emp_cluster on cluster dept_emp_cluster;

Index created.

SQL> create table dept cluster dept_emp_cluster(department_id) as select * from departments;

Table created.

SQL> create table emp cluster dept_emp_cluster(department_id) as select * from employees;

Table created.

SQL> select department_id,rowid from dept where department_id=10;

DEPARTMENT_ID ROWID
------------- ------------------
           10 AAASQWAAEAAAAOfAAA

SQL> select department_id,rowid from emp where department_id=10;

DEPARTMENT_ID ROWID
------------- ------------------
           10 AAASQWAAEAAAAOfAAA
cluster table case

结论:(摘抄,计算的数据不准确),

从上,我们看到对于dept、emp这两张不同的表,对于department_id=10的两条记
录的rowid完全一样,均为AAASQWAAEAAAAOfAAA。
其中AAASQW为数据库对象号,即转成10进制后位******;数据文件号为AAE=4,
位于第4号数据文件上;位于第4号文件的第AAAAK3=695个数据块上。
为什么会这样呢?不是说,rowid是唯一的吗,通过rowid可以唯一定位表里的一条
记录吗?可是,现在却有两张完全不同的表中的rowid竟然完全重复?
3 原来,我们这个场景比较特殊,对象号为82309的对象是一个聚簇表,而
dept,emp是位于该cluster下的。那么,emp、dept表中拥有完全重复的rowid也就不
足为奇了。因为,这本身就是聚簇表的特征。Oracle的Cluster Table就是要将不同
表中的数据放在同一个数据块中存放。关于Cluster Table我们将在后续探讨。

原文地址:https://www.cnblogs.com/arcer/p/3156331.html