How To Convert A Partitioned Table To A Non-Partitioned Table Using DataPump In 11g (Doc ID 1276049.1)

APPLIES TO:

Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Oracle Database Cloud Exadata Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Database Cloud Schema Service - Version N/A and later
Information in this document applies to any platform.
NOTE: In the images and/or the document content below, the user information and data used represents fictitious data .Any similarity to actual persons, living or dead, is purely coincidental and not intended in any manner.

GOAL

How to convert a partitioned table to a non-partitioned table using DataPump.  如何使用DataPump将分区表转换为非分区表

SOLUTION

A new import DataPump parameter PARTITION_OPTIONS has been introduced with 11g. The allowed values are:  
11g中引入了新的导入DataPump参数PARTITION_OPTIONS。允许的值为
NONE - Creates tables as they existed on the system from which the export operation was performed. This is the default value.
NONE - 创建表,该表存在于执行导出操作的系统上。这是默认值
DEPARTITION - Promotes each partition or subpartition to a new individual table. The default name of the new table will be the concatenation of the table and partition name or the table and subpartition name, as appropriate.
DEPARTITION - 将每个分区或子分区提升为新的单个表。 新表的默认名称将是表和分区名称或表和子分区名称的串联(视情况而定)。
MERGE - Combines all partitions and subpartitions into one table.
MERGE - 将所有分区和子分区合并到一个表中。
The parameter PARTITION_OPTIONS specifies how table partitions should be created during an import operation. To convert a partitioned table to a non-partitoned table we have to use PARTITION_OPTIONS=MERGE during the process of import.
参数 PARTITION_OPTIONS 指定在导入操作期间应如何创建表分区。要将分区表转换为非分区表,我们必须在导入过程中使用 PARTITION_OPTIONS = MERGE
The below example illustrates how to convert partitioned table to a non-partitioned table using expdp/impdp.
下面的示例说明了如何使用expdp / impdp将分区表转换为非分区表
1. Create a partitioned table and insert values into the partitioned table  创建一个分区表并将值插入该分区表

connect scott/<PASSWORD>
create table part_tab
(
   year    number(4),
   product varchar2(10),
   amt     number(10,2)
)
partition by range (year)
(
   partition p1 values less than (1992) tablespace u1,
   partition p2 values less than (1993) tablespace u2,
   partition p3 values less than (1994) tablespace u3,
   partition p4 values less than (1995) tablespace u4,
   partition p5 values less than (MAXVALUE) tablespace u5
);

select * from PART_TAB;

YEAR       PRODUCT    AMT
---------- ---------- ----------
      1992 p1                100
      1993 p2                200
      1994 p3                300
      1995 p4                400
      2010 p5                500

select OWNER, TABLE_NAME, PARTITIONED
from   dba_tables
where  table_name = ‘PART_TAB‘ and owner = ‘SCOTT‘;

OWNER                          TABLE_NAME PAR
------------------------------ ---------- ---
SCOTT                          PART_TAB   YES

select TABLE_OWNER, TABLE_NAME, PARTITION_NAME, TABLESPACE_NAME
from   dba_tab_partitions
where  TABLE_NAME = ‘PART_TAB‘ and TABLE_OWNER = ‘SCOTT‘;

TABLE_OWNER                    TABLE_NAME PARTITION_ TABLESPACE
------------------------------ ---------- ---------- ----------
SCOTT                          PART_TAB   P1         U1
SCOTT                          PART_TAB   P2         U2
SCOTT                          PART_TAB   P3         U3
SCOTT                          PART_TAB   P4         U4
SCOTT                          PART_TAB   P5         U5

2. Export the partitioned table:  导出分区表

#> expdp TABLES=scott.part_tab USERID="‘ / as sysdba‘" DIRECTORY=test_dir DUMPFILE=part_tab.dmp LOGFILE=part_tab.log

Export: Release 11.2.0.2.0 - Production on Thu Dec 23 08:27:24 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_TABLE_01": TABLES=scott.part_tab USERID="/******** AS SYSDBA" DIRECTORY=test_dir DUMPFILE=part_tab.dmp LOGFILE=part_tab.log
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 32 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "SCOTT"."PART_TAB":"P2" 5.898 KB 1 rows
. . exported "SCOTT"."PART_TAB":"P3" 5.898 KB 1 rows
. . exported "SCOTT"."PART_TAB":"P4" 5.898 KB 1 rows
. . exported "SCOTT"."PART_TAB":"P5" 5.914 KB 2 rows
. . exported "SCOTT"."PART_TAB":"P1" 0 KB 0 rows
Master table "SYS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TABLE_01 is:
  /tmp/part_tab.dmp
Job "SYS"."SYS_EXPORT_TABLE_01" successfully completed at 08:28:02

3. Import the table in user "USER2" to convert the partitioned table into a non-partitioned table:  导入用户“ USER2”中的表,以将分区表转换为未分区表

#> impdp USERID="‘/ as sysdba‘" TABLES=scott.part_tab DIRECTORY=test_dir DUMPFILE=part_tab.dmp LOGFILE=imp_part_tab.log REMAP_SCHEMA=scott:user2 PARTITION_OPTIONS=merge

Import: Release 11.2.0.2.0 - Production on Thu Dec 23 08:39:08 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYS"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_TABLE_01": USERID="/******** AS SYSDBA" TABLES=scott.part_tab DIRECTORY=test_dir DUMPFILE=part_tab.dmp LOGFILE=imp_part_tab.log REMAP_SCHEMA=scott:user2 PARTITION_OPTIONS=merge
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "USER2"."PART_TAB":"P2" 5.898 KB 1 rows
. . imported "USER2"."PART_TAB":"P3" 5.898 KB 1 rows
. . imported "USER2"."PART_TAB":"P4" 5.898 KB 1 rows
. . imported "USER2"."PART_TAB":"P5" 5.914 KB 2 rows
. . imported "USER2"."PART_TAB":"P1" 0 KB 0 rows
Job "SYS"."SYS_IMPORT_TABLE_01" successfully completed at 08:39:17

select * from user2.part_tab;

YEAR       PRODUCT    AMT
---------- ---------- ----------
      1992 p1                100
      1993 p2                200
      1994 p3                300
      1995 p4                400
      2010 p5                500

select OWNER, TABLE_NAME, PARTITIONED
from   dba_tables
where  table_name = ‘PART_TAB‘ and owner = ‘USER2‘;

OWNER                          TABLE_NAME PAR
------------------------------ ---------- ---
USER2                          PART_TAB   NO

select TABLE_OWNER, TABLE_NAME, PARTITION_NAME, TABLESPACE_NAME
from   dba_tab_partitions
where  TABLE_NAME = ‘PART_TAB‘ and TABLE_OWNER = ‘USER2‘;

no rows selected

Note:
------
If there is a local or global prefixed index created on the partitioned table, import with PARTITION_OPTIONS=merge also converts the index to non-partitioned.--如果在分区表上创建了本地或全局前缀索引,则使用PARTITION_OPTIONS = merge导入也会将索引转换为非分区索引。

- local prefixed index:
CREATE INDEX part_tab_loc_idx ON part_tab(year) LOCAL;

After import with REMAP_SCHEMA=scott:user2 PARTITION_OPTIONS=merge, the local prefixed index is also converted to a non-partitioned index:

select OWNER, INDEX_NAME, PARTITIONED
from dba_indexes
where index_name=‘PART_TAB_GLOB_IDX‘;
OWNER INDEX_NAME PAR
---------- -------------------- ---
SCOTT PART_TAB_LOC_IDX YES
USER2 PART_TAB_LOC_IDX NO  

  -or-

- global prefixed index:
CREATE INDEX part_tab_glob_idx ON part_tab(year)
GLOBAL PARTITION BY RANGE (year)
(partition p1 values less than (1992),
partition p2 values less than (1993),
partition p3 values less than (1994),
partition p4 values less than (1995),
partition p5 values less than (MAXVALUE)
);

After import with REMAP_SCHEMA=scott:user2 PARTITION_OPTIONS=merge, the local prefixed index is also converted to a non-partitioned index:

select OWNER, INDEX_NAME, PARTITIONED
from dba_indexes
where index_name=‘PART_TAB_GLOB_IDX‘;
OWNER INDEX_NAME PAR
---------- -------------------- ---
SCOTT PART_TAB_GLOB_IDX YES
USER2 PART_TAB_GLOB_IDX NO

Note:
1/ The DEPARTITION option is applicable to Transportable tablespace. For more details refer Note 1063299.1 - Tablespace Transport for a Single Partition.  DEPARTITION选项适用于传输表空间。有关更多详细信息,请参见注释1063299.1-单分区的表空间传输。
2/ The DEPARTITION option can be used against a Standard database, even though Partitioning isn‘t available in Standard Edition.  即使Partitioning在Standard Edition中不可用,DEPARTITION选项也可用于Standard数据库。

原文地址:https://www.cnblogs.com/zylong-sys/p/12043620.html

时间: 2024-11-06 20:59:20

How To Convert A Partitioned Table To A Non-Partitioned Table Using DataPump In 11g (Doc ID 1276049.1)的相关文章

ALTER TABLE SWITCH&#39; statement failed. The table x&#39; is partitioned while index &#39;x&#39; is not partitioned.

1.L_Monitoring有这么些字段,ID,Collecttime,PlateType,PlateNO以及其他一些这段.建立这个表的时候是个非分区表,其中ID是主键,并在Collecttime,PlateType,PlateNO上面建立了索引. 2.系统运行一阵子后,L_Monitoring数据变得非常大,5,6千万,而且后续还会更大.所以要求将L_Monitoring表进行分区.分区方案是按照Collecttime进行每天分区.Collecttime为分区字段,并将Collecttime字

解决:Reading table information for completion of table and column names

mysql -A不预读数据库信息(use dbname 更快)-Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A mysql> use dbname Reading table information for completion of table and column names You

innodb table level lock 与lock table语句关系

DDL语句只申请意向级别的表锁.在lock table语句中,mysql会申请mysql级别表锁,同时innodb也会申请innodb级别表锁.前提是innodb_table_locks=1 https://www.percona.com/blog/2012/07/31/innodb-table-locks/ MySQL Table level locks and Innodb Table Levellocks are two separate beings. You almost never

Truncate table、Delete与Drop table的区别

Truncate table.Delete与Drop table的区别 TRUNCATE TABLE 在功能上与不带 WHERE 子句的 DELETE 语句相同:二者均删除表中的全部行.但 TRUNCATE TABLE 比 DELETE 速度快,且使用的系统和事务日志资源少. DELETE 语句每次删除一行,并在事务日志中为所删除的每行记录一项.TRUNCATE TABLE 通过释放存储表数据所用的数据页来删除数据,并且只在事务日志中记录页的释放. TRUNCATE TABLE 删除表中的所有行

oracle中比较alter table t move 和alter table t shrink space

alter table t move和alter table t shrink space都可以用来进行段收缩,降低高水位HWM,也都可以用来消除行链接(Row Chaining)和行迁移(Row Migration),但是有如下区别:1)使用alter table move,会把表格最多收缩到创建表格时的storage子句指定的初始大小,使用alter table shrink space,则不受此限制.2)使用alter table move之后,索引会无效,需要重建,使用alter tab

mysql切换数据库提示警告:Reading table information for completion of table and column names

登录数据库后,选择数据库时发现以下提示, mysql> use testReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -A Database changedmysql> 意思是 预读这个库中表以及表列信息,一般原因是当库中表很多,表中数据很大时,就会出现执行use <库名>后半天

RMAN RECOVER TABLE 功能是 Oracle Database 12c 的新增功能 (Doc ID 1521524.1)

RMAN RECOVER TABLE Feature New to Oracle Database 12c (Doc ID 1521524.1) APPLIES TO: Oracle Database Cloud Schema Service - Version N/A and laterOracle Database Exadata Cloud Machine - Version N/A and laterOracle Database Exadata Express Cloud Servic

Can rename table but can not truncate table

一个表无法truncate可是能够rename,这个乍听起来认为好奇怪,以下模拟该过程. 3个session: session1运行truncate和rename操作. session2运行lock表操作: session3进行监控. session1: [[email protected] contrib]$ psql gtlions psql (8.2.15) Type "help" for help. gtlions=# \d test Table "public.te

ireport5.6使用table组件,如何用table显示javaBean数据源

1.从组件面板添加一个table组件到报表中. 2.设计table的字段头. 合并操作 1. 2. 删除你不需要的列 新增你的合并列 3.在报表Parameters里新增一个参数dets(java.util.List) 4.配置table数据集 a.重命令数据集(方便) 右键->属性,即可修改. b.添加一个Parameters 新增一个table1(net.sf.jasperreports.engine.JRDataSource) c.手动配置代码,把dets参数传递给table1接收 <d