• 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 这种写法是可以多进程同时查看数据,效率要比普通查看效果快的多,但不可在程序中这样写,因为它会独占进程,多人同时查看的话会比普通方法还要慢。

  • 相关阅读:
    zabbix监控大数据
    MongoDB
    CDH管理节点扩容磁盘步骤
    CDH的ntp时间同步
    监控文件是否更新
    crontab配置
    hue的安装
    在编译内核的最后阶段出现sdhci_esdhc_imx_pdata未定义的错误
    java程序,在windows下设置为开机自启动
    全局启动函数start_kernel函数注解
  • 原文地址:https://www.cnblogs.com/dushaojun/p/8319202.html
Copyright © 2020-2023  润新知