How to Add Multiple Partitions in Oracle 12C (Doc ID 1482456.1)

APPLIES TO:

Oracle Database - Enterprise Edition - Version 12.1.0.1 and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Database Cloud Exadata Service - Version N/A and later
Information in this document applies to any platform.
Oracle 12C

GOAL

To demonstrate new feature in 12c, adding multiple table partitions in a single command  为了演示12c中的新功能,请在单个命令中添加多个表分区

SOLUTION

NOTE: In the images and/or the document content below, the user information and data used represents fictitious data from the Oracle sample schema(s) or Public Documentation delivered with an Oracle database product.  Any similarity to actual persons, living or dead, is purely coincidental and not intended in any manner. 

You can add multiple new partitions with the ADD PARTITION clause of the ALTER TABLE statement. When adding multiple partitions, local and global index operations are the same as when adding a single partition. Note that both ADD PARTITION and ADD PARTITIONS are synonymous.
您可以使用 ALTER TABLE 语句的 ADD PARTITION 子句添加多个新分区。 添加多个分区时,本地索引和全局索引操作与添加单个分区时相同。 请注意,ADD PARTITION 和 ADD PARTITIONS 都是同义词。

RANGE PARTITIONS  范围分区

You can add multiple range partitions that are listed in ascending order of their upper bound values to the high end (after the last existing partition) of a range-partitioned or composite range-partitioned table, provided the MAXVALUE partition is not defined.
您可以将以上限值的升序排列的多个范围分区添加到范围分区表或组合范围分区表的高端(在最后一个现有分区之后),前提是未定义MAXVALUE分区。

CREATE TABLE sales
(prod_id NUMBER(6),
cust_id NUMBER,
time_id DATE,
channel_id CHAR(1),
promo_id NUMBER(6),
quantity_sold NUMBER(3),
amount_sold NUMBER(10,2))
partition by range(time_id)
(partition sales_q1_2006 values less than (TO_DATE('01-APR-2006','dd-MON-yyyy')),
partition sales_q2_2006 values less than (TO_DATE('01-JUL-2006','dd-MON-yyyy')),
partition sales_q3_2006 values less than (TO_DATE('01-OCT-2006','dd-MON-yyyy')),
partition sales_q4_2006 values less than (TO_DATE('01-JAN-2007','dd-MON-yyyy')));

The above example creates a sales table with four partitions, one for each quarter of 2006. 上面的示例创建了一个具有四个分区的sales表,
Each partition is given a name: sales_q1_2006, sales_q2_2006, sales_q3_2006, and sales_q4_2006.  每个分区用于2006年的每个季度。每个分区都有一个名称:sales_q1_2006,sales_q2_2006,sales_q3_2006和sales_q4_2006。
The time_id column is the partitioning column, while its value represents the partitioning key of a specific row.  time_id列是分区列,而其值表示特定行的分区键。
The VALUES LESS THAN clause determines the partition bound: Rows with partitioning key values that compare less than the ordered list of values specified by the clause are stored in the partition. 
VALUES LESS THAN子句确定分区的边界:分区键值的行比该子句指定的值的有序列表小的行存储在分区中。
For example, a row with time_id=17-MAR-2006 would be stored in partition sales_q1_2006.  例如,time_id = 17-MAR-2006的行将存储在分区sales_q1_2006中。

You can add multiple partitions using a single statement by specifying the individual partitions. 您可以通过指定单个分区来使用单个语句添加多个分区
For example, in the below example, you add multiple partitions to the Range-partitioned sales table created earlier named sales_q1_2007, sales_q2_2007, sales_q3_2007 and sales_q4_2007.
例如,在下面的示例中,您将多个分区添加到先前创建的名为sales_q1_2007,sales_q2_2007,sales_q3_2007和sales_q4_2007的范围分区销售表中。

ALTER TABLE sales ADD
PARTITION sales_q1_2007 VALUES LESS THAN (TO_DATE('01-APR-2007','dd-MON-yyyy')),
PARTITION sales_q2_2007 VALUES LESS THAN (TO_DATE('01-JUL-2007','dd-MON-yyyy')),
PARTITION sales_q3_2007 VALUES LESS THAN (TO_DATE('01-OCT-2007','dd-MON-yyyy')),
PARTITION sales_q4_2007 VALUES LESS THAN (TO_DATE('01-JAN-2008','dd-MON-yyyy'));

LIST PARTITIONS  列表分区

You can add multiple list partitions to a table using new sets of partition values if the DEFAULT partition does not exist.  如果DEFAULT分区不存在,则可以使用新的分区值集将多个列表分区添加到一个表中。

CREATE TABLE sales_list
(salesman_name VARCHAR2(30),
sales_state VARCHAR2(20))
PARTITION BY LIST(sales_state)
(
PARTITION sales_CA VALUES('California'),
PARTITION sales_NY VALUES ('New York'),
PARTITION sales_NJ VALUES ('New Jersey'),
PARTITION sales_CT VALUES ('Connecticut'),
PARTITION sales_PA VALUES ('Pennsylvania'),
PARTITION sales_IL VALUES('Illinois')); ALTER TABLE sales_list add
PARTITION sales_NE VALUES ('Nebraska'),
PARTITION sales_AZ VALUES ('Arizona'),
PARTITION sales_MD VALUES ('Maryland');

SYSTEM PARTITIONS  系统分区

The BEFORE clause can be used to add multiple new system partitions in relation to only one existing partition. If the clause is specified at the end of the SQL statement, then all the new partitions are added before the partition specified in the clause. Otherwise, the new partitions are added after the existing partitions.  BEFORE子句可用于仅相对于一个现有分区添加多个新系统分区。如果在SQL语句的末尾指定了子句,则所有新分区都将添加到该子句中指定的分区之前。否则,新分区将添加到现有分区之后。
For example, the following SQL statement adds three new partitions before the part_last partition for the system partitioned table:  例如,以下SQL语句在系统分区表的part_last分区之前添加了三个新分区

ALTER TABLE system_table1 ADD PARTITIONS 3 BEFORE part_last;

The following SQL statement adds multiple individual partitions using the BEFORE clause:  以下SQL语句使用BEFORE子句添加多个单独的分区

ALTER TABLE system_table2 ADD
PARTITION p5,
PARTITION p6,
PARTITION p7
BEFORE PARTITION pMax;

REFERENCES

NOTE:785462.1 - 11g New Features: System Partitioning

如何在Oracle 12C中添加多个分区 (Doc ID 1482456.1)的更多相关文章

  1. 如何在Oracle 12C中Drop/Truncate多个分区 (Doc ID 1482264.1)

    How to Drop/Truncate Multiple Partitions in Oracle 12C (Doc ID 1482264.1) APPLIES TO: Oracle Databas ...

  2. Data Guard:Oracle 12c –新增和更新的功能 (Doc ID 1558256.1)

    Data Guard: Oracle 12c – New and updated Features (Doc ID 1558256.1) APPLIES TO: Oracle Database - E ...

  3. Oracle 12c中新建pdb用户登录问题分析

    Oracle 12c新建用户登录问题分析1 用sys用户新建用户,提示公用用户名或角色名无效.原因:Oracle 12c中,在容器中建用户(或者应该称为使用者),须在用户名前加c##.默认登录连接的就 ...

  4. oracle 12c 中asm元数据是否有所变化

    详见原文博客链接地址: oracle 12c 中asm元数据是否有所变化

  5. 如何在VUE项目中添加ESLint

    如何在VUE项目中添加ESLint 1. 首先在项目的根目录下 新建 .eslintrc.js文件,其配置规则可以如下:(自己小整理了一份),所有的代码如下: // https://eslint.or ...

  6. 如何在Android Studio中添加注释模板信息?

    如何在Android Studio中添加注释模板信息? 在开发程序的时候,我们一般都会给文件自动添加上一些关于文件的注释信息,比如开发者的名字,开发的时间,开发者的联系方式等等.那么在android ...

  7. 浅析Oracle 12c中Data Guard新特性

    浅析Oracle 12c中Data Guard新特性   写在前面 无论是做Oracle运维的小伙伴还是老伙伴,想必对Oracle数据库的数据级灾备核心技术—Data Guard是再熟悉不过了!这项从 ...

  8. 为何在查询中索引未被使用 (Doc ID 1549181.1)

        To Bottom * 为何在查询中索引未被使用 (Doc ID 1549181.1) To Bottom 文档内容 用途   排错步骤   高速检查   表上是否存在索引?   索引是否应该 ...

  9. Oracle 12C 新特性之表分区或子分区的在线迁移

    Oracle 12c 中迁移表分区或子分区到不同的表空间不再需要复杂的过程.与之前版本中未分区表进行在线迁移类似,表分区或子分区可以在线或是离线迁移至一个不同的表空间.当指定了 ONLINE 语句,所 ...

随机推荐

  1. Task 的一些个人见解

    Task确实比较好用且优雅 我感觉.NET要成为艺术家... public class TheTask { /// <summary> /// 直接调用是同步方法 /// </sum ...

  2. linux—chown

    1 .修改 /usr/local下bin目录的所属者 2.修改 /usr/local下bin目录的所属组 3.修改 /usr/local下games目录的所属者和所属组 4.修改 /usr/local ...

  3. java虚拟机运行内存图

    首先针对8种常见数据类型(byte,short,int,long,double,float,char,boolean),还有String,他们在类对象被引用的时候,把数据类型存放在栈中,而常量则放在常 ...

  4. 5-- String 、StringBulid 、StringBuffer的区别

    String是典型的Immutable(不可变)类,被声明为final class,所有属性都是final的.由于它的不可变性,类似拼接.截取字符串等操作都会产生新的String对象,往往编码中常常对 ...

  5. centos7 7.3php编译安装

    1.首先更新依赖包. yum -y update 2.安装依赖包 yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bz ...

  6. 【hibernate】重写物理表名和列明

    [hibernate]重写物理表名和列明 转载:https://www.cnblogs.com/yangchongxing/p/10357123.html 假设你的数据库命名有这样的需求,表都以 yc ...

  7. 【JPA】字段访问、属性访问及混合访问

    [JPA]字段访问.属性访问及混合访问 转载:https://www.cnblogs.com/yangchongxing/p/10120318.html 1.字段访问 注解字段,通过反射来获得和设置字 ...

  8. 慢sql查询优化

    explain使用介绍 id:执行编号,标识select所属的行.如果在语句中没子查询或关联查询,只有唯一的select,每行都将显示1.否则,内层的select语句一般会顺序编号,对应于其在原始语句 ...

  9. SAP B1:如何在水晶报表中插入二维码

    动态二维码API接口地址:http://www.liantu.com/api.php?text=x备注: 动态网址内可自定义相应的字段拼接(如图5为 [批号]+[质检员]字段) 若API接口链接失效, ...

  10. 65-如何部署 Calico 网络?

    Calico 是一个纯三层的虚拟网络方案,Calico 为每个容器分配一个 IP,每个 host 都是 router,把不同 host 的容器连接起来.与 VxLAN 不同的是,Calico 不对数据 ...