在我的Oraclle 11.2中,我有一个架构MAIN,其中500个表分布在5个表空间中。 TBS1中有100个表,TBS2中有100个表等等...用户MAIN的默认值是TBS1。
有时由于某种原因我必须导出架构MAIN
expdp \'/ as sysdba\' shemas=main dumpfile=main.dmp directory=dpdumps
并将其导回到相同的表空间
impdp \'/ as sysdba\' directory=dpdumps dumpfile=main.dmp version=11.2
但导入后我在一个默认TBS1中有所有对象
我如何执行impdp以便将表格导出到导出之前的原始表空间? 我哪里错了?
谢谢。
答案 0 :(得分:0)
老实说,我不知道您实际上在做什么,但是那不是datapump的工作原理。如果表是用不同的表空间定义的,则除非指定了TRANSFORM
或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>