1

在我的 Oracle 11.2 中,我有一个架构 MAIN,其中 500 个表分布在 5 个表空间上。TBS1 中有 100 个表,TBS2 中有 100 个表,依此类推...用户 MAIN 的默认值为 TBS1。

有时由于某种原因我必须导出模式 MAIN

expdp \'/ as sysdba\' schemas=main dumpfile=main.dmp directory=dpdumps

并将其导入相同的表空间

impdp \'/ as sysdba\' directory=dpdumps dumpfile=main.dmp version=11.2

但是在导入之后,我将所有对象都放在一个默认的 TBS1 中

我如何执行 impdp 以使表像导出前一样回到原始表空间?我哪里错了?

谢谢你。

4

1 回答 1

0

老实说,我不知道您实际上在做什么,但这不是数据泵的工作方式。如果表是使用不同的表空间定义的,则导入将保留原始规范,除非指定了TRANSFORMor REMAP_TABLESPACE。否则,它将按预期工作

测试用例

SQL> create user my_test identified by "Oracle_1" ;

User created.

SQL> alter user my_test quota unlimited on tbrepdata  ;

User altered.

SQL> alter user my_test quota unlimited on tbhisdata ;

User altered.

SQL> grant create table to my_test ;

Grant succeeded.

SQL> create table my_test.test_one_tbs ( c1 number ) tablespace tbrepdata ;

Table created.

SQL> create table my_test.test_two_tbs ( c1 number ) tablespace tbhisdata ;

Table created.

SQL> declare
  2  begin
  3  for i in 1 .. 1000
  4  loop
  5  insert into my_test.test_one_tbs values ( i );
  6  insert into my_test.test_two_tbs values ( i );
  7  end loop;
  8  commit ;
  9* end;
  /

PL/SQL procedure successfully completed.

SQL> select count(*) from my_test.test_one_tbs ;

  COUNT(*)
----------
      1000

SQL> select count(*) from my_test.test_two_tbs ;

  COUNT(*)
----------
      1000

SQL> host expdp directory=DIR_DATAPUMP_EXPORT dumpfile=mytest.dmp schemas=my_test

..........
Processing object type SCHEMA_EXPORT/TABLE/TABLE
. . exported "MY_TEST"."TEST_ONE_TBS"                    12.76 KB    1000 rows
. . exported "MY_TEST"."TEST_TWO_TBS"                    12.76 KB    1000 rows
Master table "SYS"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_SCHEMA_01 is:
  /orabatch/ftpcpl/export/mytest.dmp
Job "SYS"."SYS_EXPORT_SCHEMA_01" successfully completed at Wed Aug 12 13:05:23 2020 elapsed 0 00:00:50


SQL> drop table my_test.test_one_tbs purge;

Table dropped.

SQL> drop table my_test.test_two_tbs purge ;

Table dropped.

SQL> host impdp directory=DIR_DATAPUMP_EXPORT dumpfile=mytest.dmp

......
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "MY_TEST"."TEST_ONE_TBS"                    12.76 KB    1000 rows
. . imported "MY_TEST"."TEST_TWO_TBS"                    12.76 KB    1000 rows
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
Job "SYS"."SYS_IMPORT_FULL_01" completed with 2 error(s) at Wed Aug 12 13:06:37 2020 elapsed 0 00:00:13


SQL> select tablespace_name , segment_name from dba_segments where owner = 'MY_TEST' ;

TABLESPACE_NAME
------------------------------
SEGMENT_NAME
--------------------------------------------------------------------------------
TBHISDATA
TEST_TWO_TBS

TBREPDATA
TEST_ONE_TBS


SQL>
于 2020-08-12T11:12:44.773 回答