oracle 表分區例子
阿新 • • 發佈:2017-07-10
partition bsp size cte color -- har rmi part
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、在把表建在不同的表空間上(分塊存儲數據文件) 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 表分區例子