oracle 根据在线更新分区。
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 根据在线更新分区。的更多相关文章
- 深入学习Oracle分区表及分区索引
关于分区表和分区索引(About Partitioned Tables and Indexes)对于10gR2而言,基本上可以分成几类: • Range(范围)分区 • Has ...
- oracle 分区表和分区索引
很复杂的样子,自己都没有看完,以备后用 http://hi.baidu.com/jsshm/item/cbfed8491d3863ee1e19bc3e ORACLE分区表.分区索引ORACLE对于分区 ...
- ORACLE分区表、分区索引详解
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt160 ORACLE分区表.分区索引ORACLE对于分区表方式其实就是将表分段 ...
- 【三思笔记】 全面学习Oracle分区表及分区索引
[三思笔记]全面学习Oracle分区表及分区索引 2008-04-15 关于分区表和分区索引(About PartitionedTables and Indexes) 对于 10gR2 而言,基本上可 ...
- Oracle数据库表分区
一.Oracle数据库表分区概念和理解 1.1.已经存在的表没有方法可以直接转化为分区表. 1.2.不在分区字段上建立分区索引,在别的字段上建立索引相当于全局索引.效率 ...
- 简单ORACLE分区表、分区索引
前一段听说CSDN.COM里面很多好东西,同事建议看看合适自己也可以写一写,呵呵,今天第一次开通博客,随便写点东西,就以第一印象分区表简单写第一个吧. ORACLE对于分区表方式其实就是将表分段存储, ...
- Oracle基础 表分区
Oracle基础 表分区 一.表分区 (一)表分区的分类 1.范围分区(range) 2.散列分区(hash) 3.列表分区(list) 4.复合分区:范围-哈希(range-hash).范围-列表( ...
- Oracle 分区表-Range分区
原文:http://www.tuicool.com/articles/MzeM7r 一.什么是分区表 Oracle提供了分区技术以支持VLDB(Very Large DataBase).分区表通过对分 ...
- oracle的表分区
(1.) 表空间及分区表的概念 表空间: 是一个或多个数据文件的集合,所有的数据对象都存放在指定的表空间中,但主要存放的是表, 所以称作表空间. 分区表: 当表中的数据量不断增大,查询数据的速度就 ...
随机推荐
- layui记录
layui 官网 layui 独立版 layui mobile layui 社区
- ubuntu 百度云
下载链接:https://pan.baidu.com/s/1HBu5T3PZ8JsS93PgOKnUYw提取密码:6J1A 在终端中输入命令: sudo dpkg -i bcloud_3..1_all ...
- 跟我一起使用android Studio打包react-native项目的APK
使用的是react-native的hello-world项目 第一步:创建项目 npm install -g yarn react-native-cli react-native init Aweso ...
- python3: requests模块的使用;
requests库常用于http请求,可以很方便对网页进行爬取: 主要方法(七个): 方法 解释 requests.request() 构造一个请求,支持以下各种方法 requests.get() 获 ...
- 三层结构、MVC的简介
以前总是听说什么三层结构.什么MVC,但是一直傻傻分不清这是什么意思,下面来简单介绍一下它们吧~ 1.三层结构 在 B/S 架构中,系统标准的三层架构包括:表现层.业务层.持久层 1)表现层 也就是我 ...
- 数据库基础SQL知识面试题一
数据库基础SQL知识面试题一 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 如标题所示,本篇博客主要介绍基础知识的面试题.大家可以用来测试面试者的技术水平,由于个人水平所限,难免 ...
- namenode format
https://community.hortonworks.com/content/supportkb/48981/how-to-recover-namenode-ha-when-one-accide ...
- 5.Hystrix-服务降级
所谓降级,就是当某个服务出现异常之后,服务器将不再被调用,此时服务端可以自己准备一个本地的fallback回调,返回一个缺省值. 这样做,虽然服务水平下降,但好歹可用,比直接挂掉要强,当然这也要看适合 ...
- SonarQube(代码质量管理)配置与使用
继 Sonarqube(代码质量管理)环境搭建,交大家如何配置与使用Sonarqube 1: 汉化Sonarqube: 找到 Setting --> Update Center --> A ...
- layui(八)——轮播图常见用法总结
carousel 是 layui 2.0 版本中新增的全新模块,主要适用于跑马灯/轮播等交互场景.它可以满足任何类型内容的轮播式切换操作,更可以胜任 FullPage (全屏上下轮播)的需求,简洁而不 ...