zoukankan      html  css  js  c++  java
  • oracle交换分区方法以及注意事项

    1.查看该分区有无数据

    select /*+ parallel(a 16) */ count(1) from ZJ2_GRIDLEVSTA_cell_ALL_571 partition(SYS_P16805) a --where  a.p_day=to_date('20171231','yyyymmdd');

    2.如果分区表里有主键,自增列,删掉

    alter table zj2_gridlevsta_all_571 drop primary key;
    drop index PK_ZJ2_GRIDLEVSTA_ALL_571_OID;
    alter table ZJ2_GRIDLEVSTA_CELL_ALL_571 modify oid drop identity;
    

    3.创建表,保证索引,非空约束与分区表一致

    create table ZJ2_GRIDLEVSTA_cell_ALL_571_b as select * from ZJ2_GRIDLEVSTA_cell_ALL_571 where 1=2;
    alter table ZJ2_GRIDLEVSTA_CELL_ALL_571_b modify oid not null;
    create index b_ECI_INDEX on ZJ2_GRIDLEVSTA_CELL_ALL_571_b (ECI);
    

    4.分区表和非分区表 交换分区

    alter table ZJ2_GRIDLEVSTA_cell_ALL_571 exchange partition  SYS_P16805  with table ZJ2_GRIDLEVSTA_cell_ALL_571_b;

      

    注意:要交换的分区表中不能含有自增列,主键,否则可能无法交换分区

     select /*+ parallel(a 16) */ count(1) from 这种写法是可以多进程同时查看数据,效率要比普通查看效果快的多,但不可在程序中这样写,因为它会独占进程,多人同时查看的话会比普通方法还要慢。

  • 相关阅读:
    django继承User表导致的问题
    Sublime Text 3 鼠标右键快捷选项 简单且高效
    php所有版本
    windows 安装redis
    php玩弄redis基本操作
    PHP 实现文件下载
    PHP 获取客户端的真实IP
    根据标签内个数,显示隐藏《加载更多》
    ubuntu 安装nginx+php+mysql+phpadmin环境
    面试总结
  • 原文地址:https://www.cnblogs.com/dushaojun/p/8319202.html
Copyright © 2011-2022 走看看