自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Oracle索引聚簇表的數(shù)據(jù)加載的實操

數(shù)據(jù)庫 Oracle
以下的文章主要講述的是Oracle索引聚簇表的數(shù)據(jù)加載的實際應(yīng)用以及相關(guān)實際應(yīng)用代碼的解析,以下就是文章的相關(guān)內(nèi)容的描述。

以下的文章主要是對Oracle索引聚簇表的數(shù)據(jù)加載的詳細(xì)介紹 ,如果你對Oracle索引聚簇表的數(shù)據(jù)加載的實際操作不是很了解的話,以下的文章通過一些相關(guān)的實用方案來對其進(jìn)行詳細(xì)介紹,希望你會有所收獲。

 

加載數(shù)據(jù)

向Oracle聚簇索引表中加載數(shù)據(jù)是個很講究的事情,處理方法不對,會使得聚簇的功能發(fā)揮不完全,降低查詢性能。

方法1:

首先,我增加一個很大的列char(1000),加這個列是為了讓EMP行遠(yuǎn)遠(yuǎn)大于現(xiàn)在的大小。使得一個1024的聚簇?zé)o法存儲一行記錄。不能加varchar2(1000),因為Oracle對varchar2存儲的原則是能省就省,如果數(shù)據(jù)數(shù)據(jù)不到1000,不會分配1000的空間的。char則是有多少用多少。呵呵。

 

  1. SQL> begin  
  2. for x in ( select * from scott.dept )  
  3. loop  
  4. insert into dept  
  5. values ( x.deptno, x.dname, x.loc );  
  6. insert into emp  
  7. select *  
  8. from scott.emp 9 where deptno = x.deptno;  
  9. end loop;  
  10. end;  
  11. /  
  12. begin  
  13. *  

 

第1行出現(xiàn)錯誤:ORA-02032:聚簇表無法在簇索引建立之前使用,ORA-06512:在line 4

 

  1. SQL> create index emp_dept_cluster_idx  
  2. on cluster emp_dept_cluster  
  3. ;  

 

索引已創(chuàng)建。

 

  1. SQL> alter table emp disable constraint emp_fk; 

表已更改。

 

  1. SQL> truncate cluster emp_dept_cluster; 

Oracle索引聚簇表已截斷。

 

  1. SQL> alter table emp enable constraint emp_fk; 

表已更改。

 

  1. SQL> alter table emp add data char(1000); 

表已更改。

上面的執(zhí)行錯誤說明聚簇表無法在簇索引建立之前使用。首先我們通過先加載emp表,后加載dept表的方式。

 

  1. SQL> insert into dept  
  2. select * from scott.dept;  

 

已創(chuàng)建4行。

 

  1. SQL> insert into emp  
  2. select emp.*, '*' from scott.emp  

已創(chuàng)建14行。

然后做一個查詢,通過dbms_rowid.rowid_block_number可以查看此數(shù)據(jù)所在的BLOCK ID,如果dept和emp存儲的行數(shù)據(jù)不是一個BLOCK ID ,則標(biāo)記一個'*'.查詢結(jié)果如下:

 

  1. SQL> select dept_blk, emp_blk, 2 case when dept_blk <> 
    emp_blk then '*' end flag,  
  2. deptno  
  3. from (  
  4. select dbms_rowid.rowid_block_number(dept.rowid) 
    dept_blk, 6 dbms_rowid.rowid_block_number(emp.rowid) 
    emp_blk, 7 dept.deptno 8 from emp, dept 9 where 
    emp.deptno 
    = dept.deptno  
  5. )  
  6. order by deptno  
  7. /  
  8. DEPT_BLK EMP_BLK F DEPTNO  
  9. 85 86 * 10  
  10. 85 86 * 10  
  11. 85 87 * 10  
  12. 85 85 20  
  13. 85 87 * 20  
  14. 85 86 * 20  
  15. 85 85 20  
  16. 85 86 * 20  
  17. 85 85 30  
  18. 85 86 * 30  
  19. 85 85 30  
  20. DEPT_BLK EMP_BLK F DEPTNO  
  21. 85 86 * 30  
  22. 85 85 30  
  23. 85 85 30  

 

已選擇14行。

我們發(fā)現(xiàn),通過先插入emp數(shù)據(jù),再插入dept數(shù)據(jù),導(dǎo)致大部分的emp和dept的數(shù)據(jù)都不在一個block上,這不是我們使用索引Oracle聚簇表索引的目的。

【編輯推薦】

  1. 配置Oracle RAC中應(yīng)注意的問題有哪些
  2. Oracle自增字段的實際應(yīng)用
  3. Oracle使用游標(biāo)觸發(fā)器存儲實操
  4. Oracle數(shù)據(jù)庫中表的不同的連接方式描述
  5. Oracle數(shù)據(jù)庫中表的連接方式的講解
責(zé)任編輯:佚名 來源: 博客園
相關(guān)推薦

2010-04-12 16:50:47

Oracle索引聚簇表

2010-04-01 17:14:04

Oracle索引

2010-04-21 13:43:31

Oracle聚簇索引

2010-04-15 14:18:30

Oracle創(chuàng)建

2010-09-27 11:24:37

SQL聚簇索引

2010-04-09 10:13:13

Oracle數(shù)據(jù)字典

2024-05-24 09:28:22

2010-07-14 15:04:53

SQL Sever索引

2023-06-12 08:38:23

聚簇索引排序非聚簇索引

2010-04-19 17:39:04

Oracle導(dǎo)入

2010-04-12 09:36:29

Oacle merge

2025-02-28 10:31:50

2023-04-17 10:47:49

MySQL聚簇索引

2010-04-09 15:22:57

Oracle數(shù)據(jù)庫

2010-05-04 14:10:53

Oracle表

2010-05-10 17:00:53

Oracle死鎖進(jìn)程

2010-04-19 10:50:01

Oracle轉(zhuǎn)移

2010-04-13 16:30:13

Oracle權(quán)限

2010-04-16 17:35:39

Oracle進(jìn)程

2010-04-20 13:17:44

點贊
收藏

51CTO技術(shù)棧公眾號