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博客 ” ,链接:https://blog.itpub.net/10271187/viewspace-1683286/
,如需转载,请注明出处,否则将追究法律责任。