Oracle 11g: 合并分区表-merge partition

php中文网
发布: 2016-06-07 17:28:04
原创
1583人浏览过

使用ALTER TABLE .. MERGE PARTITION语句将两个分区的内容合并到另外一个分区,两个源分区和关联的local index都会被drop,不能用

merging partitions

  使用ALTER TABLE .. MERGE PARTITION语句将两个分区的内容合并到另外一个分区,两个源分区和关联的local index都会被drop

  不能用于 hash分区表或 hash subpartitions of a composite *-hash partitioned table

  不能用于合并引用分区表(reference-partitioned table)

合并范围分区

  允许合并两个临近范围的分区到另外分区,不相邻分区无法合并。合并结果分区继承两个源分区的最大边界。

demo:

-- Create a Table with four partitions each on its own tablespace
-- Partitioned by range on the data column.
CREATE TABLE four_seasons
(
        one DATE,
        two VARCHAR2(60),
        three NUMBER
)
PARTITION  BY RANGE ( one )
(
PARTITION quarter_one
  VALUES LESS THAN ( TO_DATE('01-apr-1998','dd-mon-yyyy'))
  TABLESPACE quarter_one,

PARTITION quarter_two
  VALUES LESS THAN ( TO_DATE('01-jul-1998','dd-mon-yyyy'))
  TABLESPACE quarter_two,

PARTITION quarter_three
  VALUES LESS THAN ( TO_DATE('01-oct-1998','dd-mon-yyyy'))
  TABLESPACE quarter_three,

MacsMind
MacsMind

电商AI超级智能客服

MacsMind 131
查看详情 MacsMind

PARTITION quarter_four
  VALUES LESS THAN ( TO_DATE('01-jan-1999','dd-mon-yyyy'))
  TABLESPACE quarter_four

);

-- Create local PREFIXED index on Four_Seasons
-- Prefixed because the leftmost columns of the index match the
-- Partitioning key CREATE INDEX i_four_seasons_l ON four_seasons ( one,two )
LOCAL (
PARTITION i_quarter_one TABLESPACE i_quarter_one,
PARTITION i_quarter_two TABLESPACE i_quarter_two,
PARTITION i_quarter_three TABLESPACE i_quarter_three,
PARTITION i_quarter_four TABLESPACE i_quarter_four
);

下一步,,合并分区.

-- Merge the first two partitions
--
ALTER TABLE four_seasons
MERGE PARTITIONS quarter_one, quarter_two INTO PARTITION quarter_two
UPDATE INDEXES;

如果不显式声明 UPDATE INDEXES 语句,就必须给受影响的分区 rebuild the local index.

-- Rebuild index for quarter_two, which has been marked unusable
-- because it has not had all of the data from Q1 added to it.
-- Rebuilding the index will correct this.
--
ALTER TABLE four_seasons MODIFY PARTITION
quarter_two REBUILD UNUSABLE LOCAL INDEXES;

合并Interval Partitions
 
同RANGE一样,必须两个相邻分区才能合并
合并 List partitions则没有限制

linux

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号