eygle.com   eygle.com
eygle.com eygle
eygle.com  
 

« 《Oracle性能优化与诊断案例精选》一书出版 | Blog首页 | Oracle 数据库 12.2新特性手册 - In-Memory 增强卷 »

Oracle 12.2 新特性:自动列表分区(Auto-List Partitioning)
modb.pro

在Oracle Database 12.2 之前,如果使用列表分区,当插入的数据超过了分区列表值设定,则会抛出异常;而如果存在大量的列表值需要定义,则可能需要一一设置。

在12.2引入的新特性中 - Auto-List Partitioning 可以针对新的列表值,进行自动的分区创建,从而减少了维护的复杂性。

在文档中这样描述:

Partitioning: Auto-List Partitioning

The database automatically creates a separate (new) partition for every distinct partition key value of the table.

Auto-list partitioning removes the management burden from the DBAs to manually maintain a list of partitioned tables for a large number of distinct key values that require individual partitions. It also automatically copes with the unplanned partition key values without the need of a DEFAULT partition.

通过以下测试来简单验证一下这个特性的表征,如果是常规的列表分区,在分区缺失时会遇到ORA-14400错误:

SQL> CREATE TABLE enmotech (
  2    PartID	     integer	     not null,
  3    CretTm	     date	     not null,
  4    PartCD	     varchar2(2)     not null
  5  ) partition by list (partcd) (
  6    partition pBJ values ('BJ'),
  7    partition pCD values ('CD'),
  8    partition pGZ values ('GZ'),
  9    partition pSH values ('SH')
 10  );

Table created.

SQL> insert into enmotech values (1, sysdate, 'KM');
insert into enmotech values (1, sysdate, 'KM')
            *
ERROR at line 1:
ORA-14400: inserted partition key does not map to any partition

当设置了automatic关键字之后,分区变更为自动管理:

drop table enmotech purge;

CREATE TABLE enmotech (
  PartID	integer		not null,
  CretTm	date		not null,
  PartCD	varchar2(2)	not null
) partition by list (partcd) automatic (
  partition pBJ values ('BJ'),
  partition pCD values ('CD'),
  partition pGZ values ('GZ'),
  partition pSH values ('SH')
);

当插入一条未定义的分区数据时,新的分区被自动创建:

SQL> insert into enmotech values (1, sysdate, 'KM');

1 row created.

SQL> select partition_name from   user_tab_partitions
  2  where  table_name = 'ENMOTECH';

PARTITION_NAME
----------------------------------------------------
PBJ
PCD
PGZ
PSH
SYS_P290

如果这个自动分片的分区名不符合你的命名规则,可以通过DDL语句去修改变更:

SQL> alter table enmotech rename partition SYS_P290 to pKM;

Table altered.

SQL> select partition_name from   user_tab_partitions
  2  where  table_name = 'ENMOTECH';

PARTITION_NAME
---------------------------------------------------
PBJ
PCD
PGZ
PKM
PSH

对于已有的分区定义,可以通过关键字 automatic 和 manual 来进行分区定义的调整:

alter table PEOPLE set partitioning automatic;

alter table PEOPLE set partitioning manual;

这是Oracle Database 12.2 分区特性的众多增强之一。


历史上的今天...
    >> 2009-12-10文章:
    >> 2008-12-10文章:
    >> 2007-12-10文章:
           2007年12月10日,北京,雪
    >> 2005-12-10文章:
           品茗:太平猴魁
    >> 2004-12-10文章:
           Oracle诊断事件列表

By eygle on 2016-12-10 09:46 | Comments (0) | Oracle12c/11g | 3224 |


CopyRight © 2004~2020 云和恩墨,成就未来!, All rights reserved.
数据恢复·紧急救援·性能优化 云和恩墨 24x7 热线电话:400-600-8755 业务咨询:010-59007017-7040 or 7037 业务合作: marketing@enmotech.com