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

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. How DataPump partition table into non-partitioned table

SOLUTION

. A new new Import DataPump Parameter partition_options has been Introduced with 11g of The allowed values are:  
11g introduces a new parameter is introduced DataPump PARTITION_OPTIONS. Allowed values are
NONE  - Creates Tables The AS ON They existed from Which The Export System Operation Performed This IS WAS The default value..
NONE -  Create a table on a system performing the export operation. This is the default
DEPARTITION  - Promotes or SUBPARTITION to each Partition Table of The Individual A new new default name of The new new BE Will The concatenation of Table The Table and Table The Partition name or name and SUBPARTITION, AS Appropriate..
DEPARTITION  - each partition or sub-partition upgrade to the new single table. The default name for the new table will be tables and partition name or the name of the partition table and the sub-series (subject to availability).
MERGE -  . Combines All Partitions and SUBPARTITIONS INTO the Table One
MERGE - All and child partitions into a single table.
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 of import. To use PARTITION_OPTIONS = MERGE during the process
specified parameters partition_options how to create a table during the import operation partition. To partition table into a non-partitioned tables, we must use PARTITION_OPTIONS during import the MERGE =
of The Example below illustrates Partitioned How to Convert to Table A Table Partitioned the using non-expdp / impdp.
The following example shows how to use expdp / impdp the partition table into a non-partitioned table
1. Create a partitioned table and insert values   into the partitioned table to create a partition table and the partition table values into

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:   Export partition 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: Import user "USER2" in the table, the partition table to convert the non-partitioned table

#> 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
= table_name WHERE 'PART_TAB' and owner = 'for USER2';

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

the SELECT TABLE_OWNER, TABLE_NAME, PARTITION_NAME, TABLESPACE_NAME 
from DBA_TAB_PARTITIONS 
WHERE TABLE_NAME = 'PART_TAB' and TABLE_OWNER = 'for USER2'; 

NO Selected rows 


Note: 
------ 
the If there IS A Global or local index The prefixed Created The Partitioned Table ON, with Import also converts the pARTITION_OPTIONS = merge to non-partitioned index. 
- If you create a local or global prefix index in the partition table then introduced pARTITION_OPTIONS = merge index will also convert a non-partitioned index. - The prefixed local index: the CREATE part_tab the INDEX part_tab_loc_idx the ON (year) the 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 / IS at The DEPARTITION the Option applicable to the For More Transportable TABLESPACE the Details REFER.  Note 1,063,299.1  - the Tablespace Transport for A Single Partition.   DEPARTITION option is available for transmission table space. For more detailed information, see the comments 1063299.1- table space transmission single partition.
2 / The DEPARTITION option can be used   against a Standard database, even though Partitioning is not available in Standard Edition. Even Partitioning is not available in the Standard Edition, DEPARTITION Standard database option can also be used.

Guess you like

Origin www.cnblogs.com/zylong-sys/p/12043620.html