impdp自動建立使用者與密碼

parknkjun發表於2015-06-03
1、檢視jzh使用者下物件
JZH@jzh>select * from tab;
TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
JZH1                           TABLE
T                              TABLE
TEST                           TABLE
TEST1                          TABLE
2、建立directory
SYS@jzh>create directory dir_dmp as '/home/oracle';
Directory created.
SYS@jzh>grant read,write on directory dir_dmp to public;
Grant succeeded.
3、匯出資料
[oracle@jzh5 ~]$ expdp jzh/jzh schemas=jzh directory=dir_dmp dumpfile=jzh.dmp
Export: Release 11.2.0.3.0 - Production on Tue Jun 2 15:52:36 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit 
Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "JZH"."SYS_EXPORT_SCHEMA_01":  jzh/******** schemas=jzh directory=dir_dmp 
dumpfile=jzh.dmp 
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 319.2 MB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "JZH"."T"                                   222.2 MB 2301632 rows
. . exported "JZH"."TEST1"                               46.45 MB 4096000 rows
. . exported "JZH"."TEST"                                122.3 KB   10000 rows
. . exported "JZH"."JZH1"                                5.468 KB       4 rows
Master table "JZH"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for JZH.SYS_EXPORT_SCHEMA_01 is:
  /home/oracle/jzh.dmp
Job "JZH"."SYS_EXPORT_SCHEMA_01" successfully completed at 15:53:53
4、刪除使用者
SYS@jzh>drop user jzh cascade;
User dropped.
5、匯入資料
[oracle@jzh5 ~]$ impdp system/oracle directory=dir_dmp dumpfile=jzh.dmp schemas=jzh
Import: Release 11.2.0.3.0 - Production on Tue Jun 2 15:56:16 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit 
Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_SCHEMA_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_SCHEMA_01":  system/******** directory=dir_dmp 
dumpfile=jzh.dmp schemas=jzh 
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
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 "JZH"."T"                                   222.2 MB 2301632 rows
. . imported "JZH"."TEST1"                               46.45 MB 4096000 rows
. . imported "JZH"."TEST"                                122.3 KB   10000 rows
. . imported "JZH"."JZH1"                                5.468 KB       4 rows
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" successfully completed at 15:56:37
----成功匯入
6、使用jzh登陸
[oracle@jzh5 ~]$ sqlplus jzh/jzh
SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 2 15:57:15 2015
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
7、查詢jzh使用者下物件
JZH@jzh>select * from tab;
TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
JZH1                           TABLE
T                              TABLE
TEST                           TABLE
TEST1                          TABLE
JZH@jzh>select index_name from user_indexes where table_name='JZH1';
INDEX_NAME
------------------------------
PK_JZH1
----表與索引回來了
總結:imdp不但自動建立了使用者,而且密碼與原來一樣。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10271187/viewspace-1683286/,如需轉載,請註明出處,否則將追究法律責任。

相關文章