失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > Oracle导出导入dmp文件(exp.imp命令行)

Oracle导出导入dmp文件(exp.imp命令行)

时间:2022-04-16 13:51:03

相关推荐

Oracle导出导入dmp文件(exp.imp命令行)

1.说明

使用Oracle命令行导出导入dmp文件,

从而在两个数据库之间快速转移数据,

也可以用来作为数据库的备份,

将来可以快速恢复数据。

命令:导出exp、导入imp

步骤:

使用Oracle的exp命令将指定数据库导出为dmp文件;然后将dmp文件上传到需要导入的数据库所在服务器;使用Oracle的imp命令将dmp文件导入指定数据库。

2.导出exp

在Oracle数据库10.21.19.63上的guwei用户下,

有两张表USER_INFO,POLICY_INFO,

下面导出这两张表的所有数据,

导出命令:

exp guwei/ai123456@10.21.19.63/orcl file=guwei_user_policy.dmp tables=USER_INFO,POLICY_INFO

导出日志:

Export: Release 11.2.0.1.0 - Production on Mon Oct 28 03:08:08 Copyright (c) 1982, , Oracle and/or its affiliates. All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsExport done in AL32UTF8 character set and AL16UTF16 NCHAR character setAbout to export specified tables via Conventional Path .... . exporting table USER_INFO 150904330 rows exported. . exporting tablePOLICY_INFO 10 rows exportedExport terminated successfully without warnings.

导出说明:

这里导出1.5亿条数据,耗时4分钟左右,

导出的guwei_user_policy.dmp文件大小为7.8G。

3.上传dmp文件

将dmp文件上传到需要导入的数据库所在服务器:

scp guwei_user_policy.dmp oracle@10.21.13.14:/home/oracle/script/guwei

4.导入imp

下面把USER_INFO,POLICY_INFO这两张表导入,

导入到Oracle数据库10.21.13.14上的yuwen用户下,

导入命令:

imp yuwen/ai123456@10.21.13.14/orcl file=guwei_user_policy.dmp tables=USER_INFO,POLICY_INFO

导入日志:

Import: Release 12.1.0.2.0 - Production on Mon Oct 28 15:55:51 Copyright (c) 1982, , Oracle and/or its affiliates. All rights reserved.Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit ProductionWith the Partitioning, OLAP, Advanced Analytics and Real Application Testing optionsExport file created by EXPORT:V11.02.00 via conventional pathWarning: the objects were exported by GUWEI, not by youimport done in US7ASCII character set and AL16UTF16 NCHAR character setimport server uses AL32UTF8 character set (possible charset conversion)export client uses AL32UTF8 character set (possible charset conversion). importing GUWEI's objects into YUWEN. importing GUWEI's objects into YUWEN. . importing table"USER_INFO" 150904330 rows imported. . importing table "POLICY_INFO" 10 rows importedImport terminated successfully without warnings.

导入说明:

导入1.5亿条数据,耗时40分钟左右,性能还是比较好的。

5.三种导入导出类型

Oracle支持三种导入导出类型

分别是表方式(T方式),用户方式(U方式),全库方式(Full方式),

上面给出的示例是表方式(T方式)。

5.1 表方式(T方式)

将指定表的数据导出,

备份某个用户模式下指定的对象(表),

使用如下命令:

exp guwei/ai123456@10.21.19.63/orcl rows=y indexes=n compress=n buffer=50000000 file=exp_table.dmp log=exp_table.log tables=USER_INFO,POLICY_INFO

恢复备份数据中的指定表,

使用如下命令:

imp yuwen/ai123456@10.21.13.14/orcl fromuser=guwei touser=yuwen rows=y indexes=n commit=y buffer=50000000 ignore=n file=exp_table.dmp log=exp_table.log tables=USER_INFO,POLICY_INFO

5.2 用户方式(U方式)

将指定用户的所有对象及数据导出,

备份某个用户模式下的所有对象,

使用如下命令:

exp jnth/thpassword@oracle owner=guwei rows=y indexes=n compress=n buffer=50000000 file=exp_table.dmp log=exp_table.log

恢复备份数据的全部内容,

使用如下命令:

imp yuwen/ai123456@10.21.13.14/orcl fromuser=guwei touser=yuwen rows=y indexes=n commit=y buffer=50000000 ignore=n file=exp_table.dmp log=exp_table.log

恢复备份数据中的指定表,

使用如下命令:

imp yuwen/ai123456@10.21.13.14/orcl fromuser=guwei touser=yuwen rows=y indexes=n commit=y buffer=50000000 ignore=n file=exp_table.dmp log=exp_table.log tables=USER_INFO,POLICY_INFO

5.3 全库方式(Full方式)

将数据库中的所有对象导出,

备份完整的数据库,

使用如下命令:

exp system/systempassword@oracle rows=y indexes=n compress=n buffer=50000000 full=y file=exp_table.dmp log=exp_table.log

导入完整数据库,

使用如下命令:

imp system/systempassword@oracle rows=y indexes=n commit=y buffer=50000000 ignore=y full=y file=exp_table.dmp log=exp_table.log

6.导出导入的优缺点:

优点:

简单易行;可靠性高;不影响数据库的正常运行。

缺点:

只能提供到"某一时间点上"的恢复,不能最大可能的恢复数据;数据量大时,恢复较慢。

7.导出exp参数说明

8.导入imp参数说明

9.参考文章

Oracle数据库exp和imp方式导数据

Oracle数据库三种备份方案

如果觉得《Oracle导出导入dmp文件(exp.imp命令行)》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。