偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

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

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

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

 

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

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

方法1:

首先,我增加一個(gè)很大的列char(1000),加這個(gè)列是為了讓EMP行遠(yuǎn)遠(yuǎn)大于現(xiàn)在的大小。使得一個(gè)1024的聚簇?zé)o法存儲(chǔ)一行記錄。不能加varchar2(1000),因?yàn)镺racle對(duì)varchar2存儲(chǔ)的原則是能省就省,如果數(shù)據(jù)數(shù)據(jù)不到1000,不會(huì)分配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)錯(cuò)誤:ORA-02032:聚簇表無(wú)法在簇索引建立之前使用,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索引聚簇表已截?cái)唷?/p>

 

  1. SQL> alter table emp enable constraint emp_fk; 

表已更改。

 

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

表已更改。

上面的執(zhí)行錯(cuò)誤說(shuō)明聚簇表無(wú)法在簇索引建立之前使用。首先我們通過(guò)先加載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行。

然后做一個(gè)查詢,通過(guò)dbms_rowid.rowid_block_number可以查看此數(shù)據(jù)所在的BLOCK ID,如果dept和emp存儲(chǔ)的行數(shù)據(jù)不是一個(gè)BLOCK ID ,則標(biāo)記一個(gè)'*'.查詢結(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),通過(guò)先插入emp數(shù)據(jù),再插入dept數(shù)據(jù),導(dǎo)致大部分的emp和dept的數(shù)據(jù)都不在一個(gè)block上,這不是我們使用索引Oracle聚簇表索引的目的。

【編輯推薦】

  1. 配置Oracle RAC中應(yīng)注意的問(wèn)題有哪些
  2. Oracle自增字段的實(shí)際應(yīng)用
  3. Oracle使用游標(biāo)觸發(fā)器存儲(chǔ)實(shí)操
  4. Oracle數(shù)據(jù)庫(kù)中表的不同的連接方式描述
  5. Oracle數(shù)據(jù)庫(kù)中表的連接方式的講解
責(zé)任編輯:佚名 來(lái)源: 博客園
相關(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)建

2025-04-28 07:10:46

聚簇非聚簇索引

2010-09-27 11:24:37

SQL聚簇索引

2010-04-09 10:13:13

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

2010-07-14 15:04:53

SQL Sever索引

2024-05-24 09:28:22

2023-06-12 08:38:23

聚簇索引排序非聚簇索引

2010-04-19 17:39:04

Oracle導(dǎo)入

2010-04-12 09:36:29

Oacle merge

2025-05-06 08:55:00

2023-04-17 10:47:49

MySQL聚簇索引

2025-02-28 10:31:50

2010-04-09 15:22:57

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

2010-05-10 17:00:53

Oracle死鎖進(jìn)程

2010-05-04 14:10:53

Oracle表

2010-04-19 10:50:01

Oracle轉(zhuǎn)移

2010-04-13 16:30:13

Oracle權(quán)限
點(diǎn)贊
收藏

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