将分区表导入无分区的数据库操作方法

测试环境:oracle Release 10.2.0.1.0 , 建分区数据oracle_sid=ascii ,  无分区数据库oracle_sid=ocp10g

1.在ascii数据库中建立3个tablespaces:tbs1,tbs2,tbs3;

SQL> create tablespace tbs1 datafile 'tbs1_data1' size 10M;

Tablespace created.

SQL> create tablespace tbs2 datafile 'tbs2_data1' size 10M;

Tablespace created.

SQL> create tablespace tbs3 datafile 'tbs3_data1' size 10M;

Tablespace created.

2.建立分区数据库表tbs_t:

SQL> create table tbs_t(a int ) partition by range(a)
  2  (
  3  partition tbs1 values less than (100),
  4  partition tbs2 values less than (200),
  5  partition tbs3 values less than (maxvalue));

Table created.

3.在tbs_t中插入数据commit后数据:

SQL> select * from tbs_t;

         A
----------
         1
         2
         3
       100
       101
       102
       103
       202
       402
       502
       602

11 rows selected.

4.使用expdp导出数据表tbs_t:

E:/tmp>expdp scott/tiger directory=dump_dest tables=tbs_t parallel=2

Export: Release 10.2.0.1.0 - Production on Wednesday, 20 April, 2011 16:41:46

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Starting "SCOTT"."SYS_EXPORT_TABLE_01":  scott/******** directory=dump_dest tables=tbs_t parallel=2
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 192 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "SCOTT"."TBS_T":"TBS1"                      4.937 KB       3 rows
. . exported "SCOTT"."TBS_T":"TBS2"                      4.945 KB       4 rows
. . exported "SCOTT"."TBS_T":"TBS3"                      4.945 KB       4 rows
Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
  E:/TMP/EXPDAT.DMP
Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at 16:41:55

5.将产生的”E:/TMP/EXPDAT.DMP”文件导入无分区数据库ocp10g;

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
ocp10g

SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
TEMP
USERS
UNDOTBS2
EXAMPLE
USERTBS
USERTBS1
UNDO_SMALL

10 rows selected.

E:/tmp>impdp scott/tiger dumpfile=expdat.dmp directory=dump_dest remap_tablespace=tbs1:usertbs remap_tablespace=tbs2:usertbs remap_tablespace=tbs3:usertbs

Import: Release 10.2.0.1.0 - Production on Wednesday, 20 April, 2011 16:47:09

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Master table "SCOTT"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_FULL_01":  scott/******** dumpfile=expdat.dmp directory=dump_dest remap_tablespace=tbs1:usertbs remap_tablespace=tbs2:use
rtbs remap_tablespace=tbs3:usertbs
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."TBS_T":"TBS1"                      4.937 KB       3 rows
. . imported "SCOTT"."TBS_T":"TBS2"                      4.945 KB       4 rows
. . imported "SCOTT"."TBS_T":"TBS3"                      4.945 KB       4 rows
Job "SCOTT"."SYS_IMPORT_FULL_01" successfully completed at 16:47:22

6.imp数据成功:

SQL> conn scott/tiger
Connected.
SQL> select * from tbs_t;

         A
----------
         1
         2
         3
       100
       101
       102
       103
       202
       402
       502
       602

11 rows selected.

注:此方法只能在impdp命令中使用,imp命令没有此选项及能不remap tablespace;

你可能感兴趣的:(Oracle)