该命令在“开始菜单>>运行>>CMD”中执行
一、数据导出(exp.exe)
1、将数据库orcl完全导出,用户名system,密码accp,导出到d:\daochu.dmp文件中
exp system/accp@orcl file=d:\daochu.dmp full=y
2、将数据库orcl中scott用户的对象导出
exp scott/accp@orcl file=d:\daochu.dmp
3、将数据库orcl中的scott用户的表emp、dept导出
exp scott/accp@orcl file= d:\daochu.dmptables=(emp,dept)
4、将数据库orcl中的表空间testSpace导出
exp system/accp@orcl file=d:\daochu.dmptablespaces=(testSpace)
二、数据导入(imp.exe)
1、将d:\daochu.dmp 中的数据导入 orcl数据库中。
imp system/accp@orcl file=d:\daochu.dmpfull=y
2、如果导入时,数据表已经存在,将报错,对该表不会进行导入;加上ignore=y即可,表示忽略现有表,在现有表上追加记录。
imp scott/accp@orclfile=d:\daochu.dmp full=y ignore=y
3、将d:\daochu.dmp中的表emp导入
imp scott/accp@orcl file=d:\daochu.dmptables=(emp)
注意:
数据导出时 tables放在file后会出现警告,多表导出时更会出现异常
tables放在file前则不会。
具体过程如下:
C:\Users\Administrator>exp scott/accp@orcl tables=(emp,dept) file=E:\test.dmp;
Export: Release 11.1.0.6.0 - Production on 星期二 10月 18 10:21:43 2016
Copyright (c) 1982, 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
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
即将导出指定的表通过常规路径...
. . 正在导出表 EMP导出了 14 行
. . 正在导出表 DEPT导出了 4 行
成功终止导出, 没有出现警告。
C:\Users\Administrator>exp scott/accp@orcl tables=(emp) file=E:\test.dmp;
Export: Release 11.1.0.6.0 - Production on 星期二 10月 18 10:23:29 2016
Copyright (c) 1982, 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
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
即将导出指定的表通过常规路径...
. . 正在导出表 EMP导出了 14 行
成功终止导出, 没有出现警告。
C:\Users\Administrator>exp scott/accp@orcl file=E:\test.dmp tables=(emp);
Export: Release 11.1.0.6.0 - Production on 星期二 10月 18 10:23:48 2016
Copyright (c) 1982, 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
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
即将导出指定的表通过常规路径...
. . 正在导出表 EMP导出了 14 行
EXP-00011: SCOTT.; 不存在
导出成功终止, 但出现警告。
C:\Users\Administrator>exp scott/accp@orcl file=E:\test.dmp tables=(emp,dept);
Export: Release 11.1.0.6.0 - Production on 星期二 10月 18 10:56:57 2016
Copyright (c) 1982, 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
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
即将导出指定的表通过常规路径...
. . 正在导出表 EMP导出了 14 行
EXP-00011: SCOTT.; 不存在
导出成功终止, 但出现警告。