1)创建DIRECTORY 对象并授权给scott用户并执行导出
SQL> create directory dump as 'f:\dump';
目录已创建。
SQL> grant read,write on directory dump to scott;
授权成功。
expdp SCOTT/yang DIRECTORY=DUMP DUMPFILE=tab.cmp TABLES=DEPT,EMP-----对dept 表和emp进行逻辑备份
Export: Release 11.1.0.6.0 - Production on 星期日, 23 5月, 2010 21:36:04
Copyright (c) 2003, 2007, Oracle. All rights reserved.
连接到: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
启动 "SCOTT"."SYS_EXPORT_TABLE_01": scott/******** directory=dump dumpfile=table.dmp tables=dept,emp
正在使用 BLOCKS 方法进行估计...
处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的总估计: 128 KB
处理对象类型 TABLE_EXPORT/TABLE/TABLE
处理对象类型 TABLE_EXPORT/TABLE/INDEX/INDEX
处理对象类型 TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
处理对象类型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
处理对象类型 TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
处理对象类型 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . 导出了 "SCOTT"."DEPT" 5.937 KB 4 行
. . 导出了 "SCOTT"."EMP" 8.570 KB 14 行
已成功加载/卸载了主表 "SCOTT"."SYS_EXPORT_TABLE_01"
******************************************************************************
SCOTT.SYS_EXPORT_TABLE_01 的转储文件集为:
F:\DUMP\TABLE.DMP
作业 "SCOTT"."SYS_EXPORT_TABLE_01" 已于 21:36:20 成功完成
2)模拟误操作
SQL> conn scott/yang
已连接。
SQL> drop table emp;
表已删除。
SQL> drop table dept;
表已删除。
3)导入数据
impdp scott/yang directory-dump dumpfile=tab.dmp tables=dept,emp
Import: Release 11.1.0.6.0 - Production on 星期日, 23 5月, 2010 21:54:46
Copyright (c) 2003, 2007, Oracle. All rights reserved.
;;;
连接到: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
已成功加载/卸载了主表 "SCOTT"."SYS_IMPORT_TABLE_01"
启动 "SCOTT"."SYS_IMPORT_TABLE_01": scott/******** directory=dump dumpfile=table.dmp tables=dept,emp
处理对象类型 TABLE_EXPORT/TABLE/TABLE
处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA
. . 导入了 "SCOTT"."DEPT" 5.937 KB 4 行
. . 导入了 "SCOTT"."EMP" 8.570 KB 14 行
处理对象类型 TABLE_EXPORT/TABLE/INDEX/INDEX
处理对象类型 TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
处理对象类型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
处理对象类型 TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
处理对象类型 TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
作业 "SCOTT"."SYS_IMPORT_TABLE_01" 已于 21:54:54 成功完成
4)查询是否成功
SQL> select ename from emp;
ENAME
----------
xiaonan
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS JAMES
FORD
MILLER
已选择14行。
SQL> select * from dept;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON