zoukankan      html  css  js  c++  java
  • oracle--表分区、分区索引

     

     

     

    --|/ range分区
    create table sale(
           product_id varchar2(5), 
           sale_count number(10,2)
    )
    partition by range (sale_count)
    ( 
              partition P1 values less than (1000), 
              partition P2 values less than (2000),
              partition P3 values less than (3000) 
    );
    
    SELECT * FROM SALE;
    
    select * from user_tab_partitions;
    
    select * from sale partition(p1);
    select * from sale partition(p2);
    select * from sale partition(p3);
    select * from sale partition(p4);
    
    insert into sale values('1',500);
    insert into sale values('2',1300);
    insert into sale values('1',2441);
    commit;
    
    insert into sale values('1',3500);
    commit;
    
    alter table sale add partition p4 values less than(maxvalue);
    
    alter table sale drop partition p4;
    
    SELECT * FROM SALE for update;
    
    alter table sale enable row movement;
    
    update sale set sale_count = 1200 where product_id = '1';
    commit;
    update sale set sale_count = 500 where product_id = '1';
    
    ---------------------------------
    --本地索引
    create index inx_sale on sale(sale_count) local;
    
    select * from user_ind_partitions;
    
    --前缀索引
    create index idx_sale_global global
           partition by range(sale_count)
           (
             partition p1 values less than(),
             partition p1 values less than(maxvalue),
             
           )
    ----------------------
    create table interval_sale
    (sid int, sdate timestamp)
    partition by range(sdate)
    interval (numtoyminterval(1,'MONTH'))
    (
      partition p1 values less than (timestamp '2019-01-01 00:00:00')
    );
    
    select numtoyminterval(1,'MONTH') from dual;
    
    --flashback table emp1 to before drop;
    
    --purge recyclebin;
    
    select * from user_tab_partitions;
    
    insert into interval_sale values(1, to_timestamp('2018-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS.FF'));
    insert into interval_sale values(2, to_timestamp('2019-02-01 00:00:00','YYYY-MM-DD HH24:MI:SS.FF'));
    insert into interval_sale values(3, to_timestamp('2019-03-02 00:00:00','YYYY-MM-DD HH24:MI:SS.FF'));
    insert into interval_sale values(1, to_timestamp('2018-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS.FF'));
    insert into interval_sale values(1, to_timestamp('2020-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS.FF'));
    commit;
    
    select * from interval_sale partition(SYS_P331);
    

      

  • 相关阅读:
    记录一些笔记~
    JS里的居民们7-对象和数组转换
    JS里的居民们6-数组排序
    JS里的居民们5-数组(栈)
    MySQL设置当前时间为默认值的方法
    session过期问题
    MyIsam和InnoDB的区别
    ajax请求 json格式和数组格式总结
    wamp 2.5 开放访问权限和设置虚拟域名
    checkbox属性checked="checked"通过js已设置,但是不勾选
  • 原文地址:https://www.cnblogs.com/eadela/p/11570857.html
Copyright © 2011-2022 走看看