oracle 表分區例子

來源:互聯網
上載者:User

標籤:varchar2   file   查詢   trunc   record   rac   style   建立   name   

oracle表分區詳解-一步一步教你oracle分區表詳解   1、建立三個不同的資料表空間,類比在不同磁碟上的儲存不同範圍的資料    create tablespace test01 datafile ‘/u01/app/oracle/oradata/orcl02/test01.dbf‘ size 500m; ---資料檔案可以不再同一儲存上  create tablespace test02 datafile ‘/u01/app/oracle/oradata/orcl02/test02.dbf‘ size 500m;  create tablespace test03 datafile ‘/u01/app/oracle/oradata/orcl02/test03.dbf‘ size 500m;  2、在把表建在不同的資料表空間上(分Block Storage資料檔案)  create table graderecord  (  sno varchar2(10),  sname varchar2(20),  dormitory varchar2(3),  grade int  )  partition by range(grade)  (  partition bujige values less than(60) tablespace test01, --不及格,定界分割  partition jige values less than(85) tablespace test02, --及格  partition youxiu values less than(maxvalue) tablespace test03--優秀    )    3、在表裡插入資料    Insert into graderecord values(‘511601‘,‘魁‘,‘229‘,92);  insert into graderecord values(‘511602‘,‘凱‘,‘229‘,62);  insert into graderecord values(‘511603‘,‘東‘,‘229‘,26);  insert into graderecord values(‘511604‘,‘亮‘,‘228‘,77);  insert into graderecord values(‘511605‘,‘敬‘,‘228‘,47);  insert into graderecord(sno,sname,dormitory) values(‘511606‘,‘峰‘,‘228‘);  insert into graderecord values(‘511607‘,‘明‘,‘240‘,90);  insert into graderecord values(‘511608‘,‘楠‘,‘240‘,100);  insert into graderecord values(‘511609‘,‘濤‘,‘240‘,67);  insert into graderecord values(‘511610‘,‘博‘,‘240‘,75);  insert into graderecord values(‘511611‘,‘錚‘,‘240‘,60);    4、分別查詢結果    SQL> select * from graderecord;  select * from graderecord partition(bujige);    SNO SNAME DOR GRADE  ---------- -------------------- --- ----------  511603 ?? 229 26  511605 ?? 228 47  511602 ?? 229 62  511604 ?? 228 77  511609 ?? 240 67  511610 ?? 240 75  511611 ?? 240 60  511601 ?? 229 92  511606 ?? 228  511607 ?? 240 90  511608 ?? 240 100    11 rows selected.    SQL>  SNO SNAME DOR GRADE  ---------- -------------------- --- ----------  511603 ?? 229 26  511605 ?? 228 47    SQL> select * from graderecord partition(jige);    SNO SNAME DOR GRADE  ---------- -------------------- --- ----------  511602 ?? 229 62  511604 ?? 228 77  511609 ?? 240 67  511610 ?? 240 75  511611 ?? 240 60    SQL> select * from graderecord partition(youxiu);    SNO SNAME DOR GRADE  ---------- -------------------- --- ----------  511601 ?? 229 92  511606 ?? 228  511607 ?? 240 90  511608 ?? 240 100    SQL>  5.刪除分區trancate partition 
alter table graderecord truncate partition bujige update indexes;

看到了吧。這就是定界分割的簡單例子。 

 

oracle 表分區例子

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.