LOG_PURCHASEINFO 是没有分区之前的表,根据
LOG_PURCHASEINFO_P 分区好的表在线更新
LOG_PURCHASEINFO表,让他变成分区表。11g才可以使用list_range(列表和范围组合分区)。http://love-flying-snow.iteye.com/blog/573303 这个是11g之前的分区(11g之前不能先用列表在使用范围分区)

-- DROP MATERIALIZED VIEW  LOG_PURCHASEINFO_P;
-- DROP TABLE LOG_PURCHASEINFO_P;

-- 创建分区表
CREATE TABLE LOG_PURCHASEINFO_P (
  PURCHASEINFOGUID VARCHAR2(36 BYTE) NOT NULL
, PROVINCEAREAID VARCHAR2(6 BYTE)
, BATCHID VARCHAR2(19 BYTE)
, ORDERDETAILID VARCHAR2(100 BYTE)
, HOSPID VARCHAR2(100 BYTE)
, HOSPNAME VARCHAR2(255 BYTE)
, DRUGID VARCHAR2(100 BYTE)
, DRUGNAME VARCHAR2(255 BYTE)
, DRUGFORMCODE NUMBER(3, 0)
, DRUGFORM VARCHAR2(50 BYTE)
, DRUGSPEC VARCHAR2(255 BYTE)
, DRUGFACTOR NUMBER(8, 0)
, DRUGUNIT VARCHAR2(10 BYTE)
, DRUGMATERIAL VARCHAR2(50 BYTE)
, APPROVALNUM VARCHAR2(100 BYTE)
, FACTORYID VARCHAR2(100 BYTE)
, FACTORYNAME VARCHAR2(255 BYTE)
, VENDORID VARCHAR2(100 BYTE)
, VENDORNAME VARCHAR2(255 BYTE)
, PURCOUNT NUMBER(10, 0)
, PURPRICE NUMBER(12, 2)
, PURTIME DATE
, PURSTATUS NUMBER(2, 0)
, HANDWAY NUMBER(10, 0)
, SOUREID VARCHAR2(36 BYTE)
, SOURETIME DATE
, ADDTIME DATE
, DRUGSPECUNIT VARCHAR2(1 BYTE)
)
PARTITION BY LIST(PROVINCEAREAID)
SUBPARTITION BY RANGE(BATCHID)
(
  -- 110000 北京
  partition p11 values ('110000') tablespace TS_YGPT (
    subpartition sp11_2015 values less than ('1120160000000000000') tablespace TS_YGPT,
    subpartition sp11_2016 values less than ('1120170000000000000') tablespace TS_YGPT,
    subpartition sp11_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 120000 天津
  partition p12 values ('120000') tablespace TS_YGPT (
    subpartition sp12_2015 values less than ('1220160000000000000') tablespace TS_YGPT,
    subpartition sp12_2016 values less than ('1220170000000000000') tablespace TS_YGPT,
    subpartition sp12_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 130000 河北省
  partition p13 values ('130000') tablespace TS_YGPT (
    subpartition sp13_2015 values less than ('1320160000000000000') tablespace TS_YGPT,
    subpartition sp13_2016 values less than ('1320170000000000000') tablespace TS_YGPT,
    subpartition sp13_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 140000 山西省
  partition p14 values ('140000') tablespace TS_YGPT (
    subpartition sp14_2015 values less than ('1420160000000000000') tablespace TS_YGPT,
    subpartition sp14_2016 values less than ('1420170000000000000') tablespace TS_YGPT,
    subpartition sp14_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 150000 内蒙
  partition p15 values ('150000') tablespace TS_YGPT (
    subpartition sp15_2015 values less than ('1520160000000000000') tablespace TS_YGPT,
    subpartition sp15_2016 values less than ('1520170000000000000') tablespace TS_YGPT,
    subpartition sp15_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 210000 辽宁
  partition p21 values ('210000') tablespace TS_YGPT (
    subpartition sp21_2015 values less than ('2120160000000000000') tablespace TS_YGPT,
    subpartition sp21_2016 values less than ('2120170000000000000') tablespace TS_YGPT,
    subpartition sp21_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 220000 吉林
  partition p22 values ('220000') tablespace TS_YGPT (
    subpartition sp22_2015 values less than ('2220160000000000000') tablespace TS_YGPT,
    subpartition sp22_2016 values less than ('2220170000000000000') tablespace TS_YGPT,
    subpartition sp22_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 230000 黑龙江
  partition p23 values ('230000') tablespace TS_YGPT (
    subpartition sp23_2015 values less than ('2320160000000000000') tablespace TS_YGPT,
    subpartition sp23_2016 values less than ('2320170000000000000') tablespace TS_YGPT,
    subpartition sp23_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 310000 上海
  partition p31 values ('310000') tablespace TS_YGPT (
    subpartition sp31_2015 values less than ('3120160000000000000') tablespace TS_YGPT,
    subpartition sp31_2016 values less than ('3120170000000000000') tablespace TS_YGPT,
    subpartition sp31_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 320000 江苏
  partition p32 values ('320000') tablespace TS_YGPT (
    subpartition sp32_2015 values less than ('3220160000000000000') tablespace TS_YGPT,
    subpartition sp32_2016 values less than ('3220170000000000000') tablespace TS_YGPT,
    subpartition sp32_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 330000 浙江
  partition p33 values ('330000') tablespace TS_YGPT (
    subpartition sp33_2015 values less than ('3320160000000000000') tablespace TS_YGPT,
    subpartition sp33_2016 values less than ('3320170000000000000') tablespace TS_YGPT,
    subpartition sp33_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 340000 安徽
  partition p34 values ('340000') tablespace TS_YGPT (
    subpartition sp34_2015 values less than ('3420160000000000000') tablespace TS_YGPT,
    subpartition sp34_2016 values less than ('3420170000000000000') tablespace TS_YGPT,
    subpartition sp34_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 350000 福建
  partition p35 values ('350000') tablespace TS_YGPT (
    subpartition sp35_2015 values less than ('3520160000000000000') tablespace TS_YGPT,
    subpartition sp35_2016 values less than ('3520170000000000000') tablespace TS_YGPT,
    subpartition sp35_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 360000 江西
  partition p36 values ('360000') tablespace TS_YGPT (
    subpartition sp36_2015 values less than ('3620160000000000000') tablespace TS_YGPT,
    subpartition sp36_2016 values less than ('3620170000000000000') tablespace TS_YGPT,
    subpartition sp36_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 370000 山东
  partition p37 values ('370000') tablespace TS_YGPT (
    subpartition sp37_2015 values less than ('3720160000000000000') tablespace TS_YGPT,
    subpartition sp37_2016 values less than ('3720170000000000000') tablespace TS_YGPT,
    subpartition sp37_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 410000 河南
  partition p41 values ('410000') tablespace TS_YGPT (
    subpartition sp41_2015 values less than ('4120160000000000000') tablespace TS_YGPT,
    subpartition sp41_2016 values less than ('4120170000000000000') tablespace TS_YGPT,
    subpartition sp41_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 420000 湖北
  partition p42 values ('420000') tablespace TS_YGPT (
    subpartition sp42_2015 values less than ('4220160000000000000') tablespace TS_YGPT,
    subpartition sp42_2016 values less than ('4220170000000000000') tablespace TS_YGPT,
    subpartition sp42_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 430000 湖南
  partition p43 values ('430000') tablespace TS_YGPT (
    subpartition sp43_2015 values less than ('4320160000000000000') tablespace TS_YGPT,
    subpartition sp43_2016 values less than ('4320170000000000000') tablespace TS_YGPT,
    subpartition sp43_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 440000 广东
  partition p44 values ('440000') tablespace TS_YGPT (
    subpartition sp44_2015 values less than ('4420160000000000000') tablespace TS_YGPT,
    subpartition sp44_2016 values less than ('4420170000000000000') tablespace TS_YGPT,
    subpartition sp44_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 450000 广西
  partition p45 values ('450000') tablespace TS_YGPT (
    subpartition sp45_2015 values less than ('4520160000000000000') tablespace TS_YGPT,
    subpartition sp45_2016 values less than ('4520170000000000000') tablespace TS_YGPT,
    subpartition sp45_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 460000 海南
  partition p46 values ('460000') tablespace TS_YGPT (
    subpartition sp46_2015 values less than ('4620160000000000000') tablespace TS_YGPT,
    subpartition sp46_2016 values less than ('4620170000000000000') tablespace TS_YGPT,
    subpartition sp46_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 490000 湖北2
  partition p49 values ('490000') tablespace TS_YGPT (
    subpartition sp49_2015 values less than ('4920160000000000000') tablespace TS_YGPT,
    subpartition sp49_2016 values less than ('4920170000000000000') tablespace TS_YGPT,
    subpartition sp49_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 500000 重庆
  partition p50 values ('500000') tablespace TS_YGPT (
    subpartition sp50_2015 values less than ('5020160000000000000') tablespace TS_YGPT,
    subpartition sp50_2016 values less than ('5020170000000000000') tablespace TS_YGPT,
    subpartition sp50_9999 values less than (maxvalue) tablespace TS_YGPT

  ),
  -- 510000 四川
  partition p51 values ('510000') tablespace TS_YGPT (
    subpartition sp51_2015 values less than ('5120160000000000000') tablespace TS_YGPT,
    subpartition sp51_2016 values less than ('5120170000000000000') tablespace TS_YGPT,
    subpartition sp51_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 520000 贵州
  partition p52 values ('520000') tablespace TS_YGPT (
    subpartition sp52_2015 values less than ('5220160000000000000') tablespace TS_YGPT,
    subpartition sp52_2016 values less than ('5220170000000000000') tablespace TS_YGPT,
    subpartition sp52_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 530000 云南
  partition p53 values ('530000') tablespace TS_YGPT (
    subpartition sp53_2015 values less than ('5320160000000000000') tablespace TS_YGPT,
    subpartition sp53_2016 values less than ('5320170000000000000') tablespace TS_YGPT,
    subpartition sp53_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 540000 西藏
  partition p54 values ('540000') tablespace TS_YGPT (
    subpartition sp54_2015 values less than ('5420160000000000000') tablespace TS_YGPT,
    subpartition sp54_2016 values less than ('5420170000000000000') tablespace TS_YGPT,
    subpartition sp54_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 610000 陕西
  partition p61 values ('610000') tablespace TS_YGPT (
    subpartition sp61_2015 values less than ('6120160000000000000') tablespace TS_YGPT,
    subpartition sp61_2016 values less than ('6120170000000000000') tablespace TS_YGPT,
    subpartition sp61_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 620000 甘肃
  partition p62 values ('620000') tablespace TS_YGPT (
    subpartition sp62_2015 values less than ('6220160000000000000') tablespace TS_YGPT,
    subpartition sp62_2016 values less than ('6220170000000000000') tablespace TS_YGPT,
    subpartition sp62_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 630000 青海
  partition p63 values ('630000') tablespace TS_YGPT (
    subpartition sp63_2015 values less than ('6320160000000000000') tablespace TS_YGPT,
    subpartition sp63_2016 values less than ('6320170000000000000') tablespace TS_YGPT,
    subpartition sp63_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 640000 宁夏
  partition p64 values ('640000') tablespace TS_YGPT (
    subpartition sp64_2015 values less than ('6420160000000000000') tablespace TS_YGPT,
    subpartition sp64_2016 values less than ('6420170000000000000') tablespace TS_YGPT,
    subpartition sp64_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- 650000 新疆
  partition p65 values ('650000') tablespace TS_YGPT (
    subpartition sp65_2015 values less than ('6520160000000000000') tablespace TS_YGPT,
    subpartition sp65_2016 values less than ('6520170000000000000') tablespace TS_YGPT,
    subpartition sp65_9999 values less than (maxvalue) tablespace TS_YGPT
  ),
  -- other
  partition p99 values (default) tablespace TS_YGPT
);

CREATE UNIQUE INDEX PK_LPIP_GUID ON LOG_PURCHASEINFO_P (PURCHASEINFOGUID ASC) parallel 8;

-- 0. 收集表的统计信息
exec dbms_stats.gather_table_stats('YGPT', 'LOG_PURCHASEINFO', cascade => true);

-- 1. 检查重定义的合理性
exec dbms_redefinition.can_redef_table('YGPT', 'LOG_PURCHASEINFO');

-- 2. 开始重定义
BEGIN
  DBMS_REDEFINITION.start_redef_table(
  uname => 'YGPT',
  orig_table => 'LOG_PURCHASEINFO',
  int_table => 'LOG_PURCHASEINFO_P');
END;

-- 3. 同步新表,这是可选的操作
BEGIN
  dbms_redefinition.sync_interim_table(
  uname => 'YGPT',
  orig_table => 'LOG_PURCHASEINFO',
  int_table => 'LOG_PURCHASEINFO_P');
END;

-- 4. 收集表的统计信息
exec dbms_stats.gather_table_stats('YGPT', 'LOG_PURCHASEINFO_P', cascade => true);

-- 5. 结束重定义
BEGIN
  dbms_redefinition.finish_redef_table(
  uname => 'YGPT',
  orig_table => 'LOG_PURCHASEINFO',
  int_table => 'LOG_PURCHASEINFO_P');
END;

-- 创建local索引
create index idx_lpi_odids on LOG_PURCHASEINFO(ORDERDETAILID) local parallel 4;
create index idx_lpi_batchid on LOG_PURCHASEINFO(BATCHID) local parallel 4;

select * from log_purchaseinfo WHERE BATCHID = '4220150111201507022'

SELECT * FROM LOG_PURCHASEINFO SUBPARTITION(SP42_2015)

select /*+ parallel(t 4) */ count(1) from log_purchaseinfo t

  

oracle 根据在线更新分区。的更多相关文章

  1. 深入学习Oracle分区表及分区索引

    关于分区表和分区索引(About Partitioned Tables and Indexes)对于10gR2而言,基本上可以分成几类: •       Range(范围)分区 •       Has ...

  2. oracle 分区表和分区索引

    很复杂的样子,自己都没有看完,以备后用 http://hi.baidu.com/jsshm/item/cbfed8491d3863ee1e19bc3e ORACLE分区表.分区索引ORACLE对于分区 ...

  3. ORACLE分区表、分区索引详解

    详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt160 ORACLE分区表.分区索引ORACLE对于分区表方式其实就是将表分段 ...

  4. 【三思笔记】 全面学习Oracle分区表及分区索引

    [三思笔记]全面学习Oracle分区表及分区索引 2008-04-15 关于分区表和分区索引(About PartitionedTables and Indexes) 对于 10gR2 而言,基本上可 ...

  5. Oracle数据库表分区

    一.Oracle数据库表分区概念和理解         1.1.已经存在的表没有方法可以直接转化为分区表.         1.2.不在分区字段上建立分区索引,在别的字段上建立索引相当于全局索引.效率 ...

  6. 简单ORACLE分区表、分区索引

    前一段听说CSDN.COM里面很多好东西,同事建议看看合适自己也可以写一写,呵呵,今天第一次开通博客,随便写点东西,就以第一印象分区表简单写第一个吧. ORACLE对于分区表方式其实就是将表分段存储, ...

  7. Oracle基础 表分区

    Oracle基础 表分区 一.表分区 (一)表分区的分类 1.范围分区(range) 2.散列分区(hash) 3.列表分区(list) 4.复合分区:范围-哈希(range-hash).范围-列表( ...

  8. Oracle 分区表-Range分区

    原文:http://www.tuicool.com/articles/MzeM7r 一.什么是分区表 Oracle提供了分区技术以支持VLDB(Very Large DataBase).分区表通过对分 ...

  9. oracle的表分区

    (1.) 表空间及分区表的概念 表空间: 是一个或多个数据文件的集合,所有的数据对象都存放在指定的表空间中,但主要存放的是表, 所以称作表空间.   分区表: 当表中的数据量不断增大,查询数据的速度就 ...

随机推荐

  1. MySQL课堂小测

    目录 一.基本知识与操作方法 二.小测具体内容 (一)向数据库表中添加记录 (二)下载并导入world.sql (三)数据库查询与输出 (四)查询数据库并求某字段和 (五)查询数据库并取最大& ...

  2. UVALive - 4225(贪心)

    题目链接:https://vjudge.net/contest/244167#problem/F 题目: Given any integer base b ≥ 2, it is well known ...

  3. Python3 与 C# 基础语法对比(String专栏)

      Code:https://github.com/lotapp/BaseCode 多图旧排版:https://www.cnblogs.com/dunitian/p/9119986.html 在线编程 ...

  4. 【洛谷P2257】YY的GCD

    题目大意:有 \(T\) 个询问,每个询问给定 \(N, M\),求 \(1\le x\le N, 1\le y\le M\) 且 \(gcd(x, y)\) 为质数的 \((x, y)\) 有多少对 ...

  5. 【洛谷P4144】大河的序列

    题目大意:给定一个长度为 N 的序列,求序列中连续区间最大的(或和加与和)是多少. 题解: 引理:任意两个数 \(i, j\),若 \(i>j\),则在二进制表示下,i 对应的二进制串的字典序一 ...

  6. POJ 2253 Frogger (Floyd)

    Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions:57696   Accepted: 18104 Descript ...

  7. python之OpenCv

    1.安装 pip install opencv-python 2.初步简绍 创建窗口显示图像 cv2.namedWindow(窗口名称[,窗口标识]) 例如:cv2.namedWindow(" ...

  8. springcloud使用zookeeper作为config的配置中心

    https://blog.csdn.net/CSDN_Stephen/article/details/78856323 仓库更新了,本地如何更新: 使用configserver作为配置中心: http ...

  9. zookeeper的监控

    1.idea插件: zookeeper https://blog.csdn.net/long290046464/article/details/52974061 优点:直接查看,不用来回切换监控 缺点 ...

  10. HDU5542 BIT优化dp

    http://acm.hdu.edu.cn/showproblem.php?pid=5542 题意:求严格递增的长度为M的序列的组数. 当dp的优化方案不那么容易一眼看出来的时候,我们可以考虑先写一个 ...