impdp命令在导入数据时,如果用户存在,则会自动创建该用户,因为expdp导出的dmp文件中包含了创建用户的脚本信息(包括密码,缺省表空间,临时表空间等)。
impdp自动创建用户有一个前提条件,就是需要首先创建用户的缺省表空间和临时表空间,如果缺省表空间或者临时表空间不存在,则自动创建用户会失败,导致导入数据的失败。
下面通过实验来描述impdp自动创建用户的前提条件和应用场景[@more@]
一.
创建表空间和用户
SQL> create
tablespace aidu datafile '/oradata/gridctl/aidu01.dbf' size 128m extent
management local segment space management auto logging;
Tablespace
created.
SQL> create
temporary tablespace temp2 tempfile '/oradata/gridctl/temp021.dbf' size 128m
extent management local;
Tablespace
created.
SQL> create user
aidu profile default identified by "aidutest" default tablespace aidu
temporary tablespace temp2 account unlock;
User
created.
SQL> grant
resource,connect to aidu;
Grant succeeded.
SQL> conn
aidu/aidutest
Connected.
SQL> create table
test (id number(10) not null,name varchar2(20));
Table created.
SQL> insert into
test values(1,'first');
1 row created.
SQL> insert into
test select id+1,name from test;
1 row created.
SQL> insert into
test select id+2,name from test;
2 rows created.
SQL> select * from
test;
ID NAME
----------
--------------------
1 first
2 first
3 first
4 first
SQL> commit;
Commit
complete.
二.创建DIRECTORY,导出用户的数据