zoukankan      html  css  js  c++  java
  • oracle 表分区例子

    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;

    看到了吧。这就是范围分区的简单例子。 

  • 相关阅读:
    轻量级web富文本框——wangEditor使用手册(3)——如何自定义配置菜单
    轻量级web富文本框——wangEditor使用手册(2)——扩展一个“缩进”功能
    轻量级web富文本框——wangEditor使用手册(1)——基本应用 demo
    由于没有远程桌面授权服务器可以提供许可证,远程会话被中断。
    java class 文件
    java类型生命周期
    (转)LSTM神经网络介绍
    (转)Skyline timeseries异常判定算法
    (转)isolation forest进行异常点检测
    (转)颜色直方图, HSV直方图, histogram bins
  • 原文地址:https://www.cnblogs.com/kexb/p/7143261.html
Copyright © 2011-2022 走看看