Home Database Mysql Tutorial Oracle中addsplit partition对globallocal index的影响

Oracle中addsplit partition对globallocal index的影响

Jun 07, 2016 pm 04:00 PM

生产库中某些大表的分区异常,需要对现有表进行在线操作,以添加丢失分区,因为是生产库,还是谨慎点好,今天有空,针对addspli

生产库中某些大表的分区异常,需要对现有表进行在线操作,以添加丢失分区,因为是生产库,还是谨慎点好,今天有空,针对add&split分区对global&local索引的影响进行了测试,测试版本为Oracle11.2.0.4,过程如下:

首先,创建分区表:

CREATE TABLE TP1
(
C1 INT PRIMARY KEY,
C2 VARCHAR2(10),
C3 CHAR(10)
)                     
partition by range (c1)
(
partition p1 values less than(6),
partition p2 values less than(11),
partition p3 values less than(16),
partition maxvalue values less than(maxvalue));
但在add partition时遇到了问题,报错如下:

ORA-14074: 分区界限必须调整为高于最后一个分区界限


根本原因是存在最后maxvalue分区,于是,再创建一个不带maxvalue的分区表:

CREATE TABLE TP2
(
C1 INT PRIMARY KEY,
C2 VARCHAR2(10),
C3 CHAR(10)
)                     
partition by range (c1)
(
partition p1 values less than(6),
partition p2 values less than(11),
partition p3 values less than(16));


然后,,创建local索引:

create index idx_tp2_c2 on tp2(c2) local;

因为主键就是个global索引,所以,不需要另外创建global index,我们insert数据:

insert into tp2 vlaues(1,'aaa','aaa');

insert into tp2 vlaues(2,'aaa','aaa');


insert into tp2 vlaues(3,'aaa','aaa');

insert into tp2 vlaues(4,'aaa','aaa');


insert into tp2 vlaues(5,'aaa','aaa');
insert into tp2 vlaues(6,'aaa','aaa');

insert into tp2 vlaues(7,'aaa','aaa');

insert into tp2 vlaues(8,'aaa','aaa');


insert into tp2 vlaues(9,'aaa','aaa');

insert into tp2 vlaues(10,'aaa','aaa');

commit;

我们add partition:

 ALTER TABLE tp2 add PARTITION p10 values less than(51);

add partition成功,因为不存在maxvalue分区,而且,add partition对global和local索引均无影响;


那么,split partition:

ALTER TABLE tp2 SPLIT PARTITION p2 AT (8) INTO (PARTITION p2, PARTITION p22) ;


发现split分区会导致golbal索引失效,而local索引正常,为split分区命令添加update indexes选项后,再split分区对global&local索引均无影响:

ALTER TABLE tp2 SPLIT PARTITION p1 AT (3) INTO (PARTITION p1, PARTITION p11) update indexes;

以上为测试结果,记录于此,以便今后其他同学和自己参考。

本文永久更新链接地址

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Reduce the use of MySQL memory in Docker Reduce the use of MySQL memory in Docker Mar 04, 2025 pm 03:52 PM

Reduce the use of MySQL memory in Docker

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

How do you alter a table in MySQL using the ALTER TABLE statement?

How to solve the problem of mysql cannot open shared library How to solve the problem of mysql cannot open shared library Mar 04, 2025 pm 04:01 PM

How to solve the problem of mysql cannot open shared library

What is SQLite? Comprehensive overview What is SQLite? Comprehensive overview Mar 04, 2025 pm 03:55 PM

What is SQLite? Comprehensive overview

Run MySQl in Linux (with/without podman container with phpmyadmin) Run MySQl in Linux (with/without podman container with phpmyadmin) Mar 04, 2025 pm 03:54 PM

Run MySQl in Linux (with/without podman container with phpmyadmin)

How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)? How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)? Mar 18, 2025 pm 12:00 PM

How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)?

Running multiple MySQL versions on MacOS: A step-by-step guide Running multiple MySQL versions on MacOS: A step-by-step guide Mar 04, 2025 pm 03:49 PM

Running multiple MySQL versions on MacOS: A step-by-step guide

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

How do I configure SSL/TLS encryption for MySQL connections?

See all articles