
prompt 
prompt 删除之前表eoda.emp_cluster_index eoda.dept 中的数据
begin 
    delete from eoda.emp_cluster_index;
    delete from eoda.dept;
    commit;
end;
/

prompt 
prompt 向表eoda.dept中插入数据
begin 
    insert into eoda.dept 
        (deptno,dname,loc) 
    select deptno + r,dname,loc  
      from scott.dept,(select level r from dual connect by level < 10);
    commit;
end;
/

prompt 
prompt 向表eoda.emp_cluster_index 表中插入数据
begin 
    insert into eoda.emp_cluster_index 
        (empno,ename,job,mgr,hiredate,sal,comm,deptno)
    select 
        rownum,ename,job,mgr,hiredate,sal,comm,deptno + r 
    from 
        scott.emp, 
        (select level r from dual connect by level < 10),
        (select level r2 from dual connect by level < 8);
    commit;
end;
/

prompt 
prompt 查询结果
select 
    min(count(*)),max(count(*)),avg(count(*))
from eoda.dept 
group by dbms_rowid.rowid_block_number(rowid);
/

prompt 
prompt 所有数据都得到妥善存储，完全没有emp_cluster_index表中的记录与相对应dept记录在不同块上存储的情况
select * from 
(
    select 
        dept_blk,emp_blk,case when dept_blk <> emp_blk then '*' end flag,deptno
    from
        (select 
            dbms_rowid.rowid_block_number(dept.rowid) dept_blk, 
            dbms_rowid.rowid_block_number(emp_cluster_index.rowid) emp_blk,
            dept.deptno 
        from emp_cluster_index,dept 
        where emp_cluster_index.deptno = dept.deptno 
        )
)
where flag = '*' 
order by deptno 
/
