Heim  >  Artikel  >  Datenbank  >  Oracle 11g的新特性分区:System Partition

Oracle 11g的新特性分区:System Partition

WBOY
WBOYOriginal
2016-06-07 16:48:591170Durchsuche

单就Partition技术本身而言,11g是一个重要的版本。一些自动化分区技术、增强策略在11g中推出。比如引用分区(Reference Partiti

Partition分区是Oracle一直以来推出的性能、管理优化技术。在Oracle数据库技术体系中,Partition是归属在DW(Data Warehouse)体系中,,也就是Oracle官方认定的处理大数据策略。
 
单就Partition技术本身而言,11g是一个重要的版本。一些自动化分区技术、增强策略在11g中推出。比如引用分区(Reference Partition)、间断分区(Interval Partition)、虚拟列分区(Partitioning Virtual Columns)、系统分区(System Partition)和拓展组合分区(Extended Composite Partitioning)。
 
本篇目的介绍11g的System Partition特性。

--------------------------------------分割线 --------------------------------------

 Oracle 11g新特性:RMAN脚本中使用替换变量

Oracle 11g 新特性 -- Result Cache(结果高速缓存)说明

Oracle 11g 新特性 -- 自动诊断资料档案库(ADR) 说明

Oracle 11g 新特性 -- DB_ULTRA_SAFE 参数 说明

Oracle 11g 新特性 -- SQL Plan Management 说明

Oracle 11g 新特性 -- 管理 SPFILE 说明

--------------------------------------分割线 --------------------------------------

1、环境介绍
 
 

笔者选择Oracle 11R2作为实验对象。
 
 

 

SQL> select * from v$version;
 
 

BANNER
 
--------------------------------------------------------------------------------
 
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
 
PL/SQL Release 11.2.0.1.0 - Production
 
CORE    11.2.0.1.0    Production
 
 

TNS for Linux: Version 11.2.0.1.0 - Production
 
NLSRTL Version 11.2.0.1.0 – Production
 
 

 

2、System Partition
 
 

我们在其他的Partition类型中,都会面对一个问题就是分区键选择。所谓分区Partition,就是将一个数据表段segment拆分为多个存储段保存。传统意义上的Partition停留在定义层面,只要我们在数据表定义的时候确定好分区键和分区策略。之后的使用数据表的过程中,我们其实对分区是“透明”的。
 
如果进行数据表的DML操作和select操作,我们是不需要指定、也无法控制数据记录插入到哪个分区中的。只有一种情况不同,就是修改分区键。如果修改分区键,并且修改分区键会影响到分区布局,这样的DML操作是不允许的。
 
11g的System Partition提供了不同选择。它提供给SQL DML操作者一种选择,让可以指定出“希望将数据保存”在哪个地方。
 
创建System Partition的过程,也是在定义数据表的过程中需要确定。
 
 

 

SQL> create table t partition by system (partition p1 tablespace users,
 
  2  partition p2 tablespace EXAMPLE) as select * from dba_objects where 1=0 ;
 
 

create table t partition by system (partition p1 tablespace users,
 
partition p2 tablespace EXAMPLE) as select * from dba_objects where 1=0
 
 

ORA-14704: 不允许对 SYSTEM 分区表执行以下操作: Create table as select
 
 

 

在system partition中,我们不允许对分区进行spilt操作和cats操作。正确的处理方式,如下:
 
 

 

SQL> create table t
 
  2  (owner varchar2(100),
 
  3  object_name varchar2(1000),
 
  4  object_id number)
 
  5  partition by system
 
  6  (partition p1 tablespace users,
 
  7  partition p2 tablespace example);
 
 

Table created
 
 

 

在语句中,我们指定了数据表采用分区策略——system策略,设定了两个分区p1和p2,并且指定了两个分区的表空间存储位置。
 
注意:这个过程中,我们没有指定分区规则,也就是没有告诉数据库当一个数据插入的时候,如何进行数据分堆。
 
检查数据字典,确定段结构情况。
 
 

 

SQL> select segment_name, partition_name, segment_type from dba_segments where owner='SCOTT' and segment_name='T';
 
 

SEGMENT_NAME        PARTITION_NAME      SEGMENT_TYPE
 
-------------------- -------------------- ------------------
 
T                    P1                  TABLE PARTITION
 
T                    P2                  TABLE PARTITION
 
 

SQL> select partitioning_type from dba_part_tables where owner='SCOTT' and table_name='T';
 
 

PARTITIONING_TYPE
 
-----------------
 
SYSTEM
 
 

 

分区类型,确定为system partition。在system partiton中,也可以创建local index对象。
 
 

 

SQL> create index idx_t_id on t(object_id) local;
 
 

Index created
 
 

SQL> select segment_name, partition_name, segment_type from dba_segments where owner='SCOTT' and segment_name='IDX_T_ID';
 
 

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn