oracle exp备份原理,oracle逻辑备份恢复(exp/imp篇)

数据导出工具EXP

EXP是客户端工具,该工具不仅可以在oracle客户端使用,还可以在oracle服务器端使用。当在oracle客户端使用EXP工具时,必须带有连接字符串;当在oracle服务器端使用EXP工具时,可以不带字符串。导出包括导出表、导出方案、导出数据库三种模式。

(1)导出表

导出表是指使用EXP工具将一个或多个表的结构和数据存储到OS文件中,导出表是使用TABLES选项来完成的。

普通用户可以导出其自身方案的所有表,但如果要导出其他方案的表,则要求该用户必须具有EXP_FULL_DATABASE角色或DBA角色。另外当导出表时,默认情况下会导出相应表上的所有索引、触发器、约束。下面以SYSTEM用户导出SCOTT.DEPT表为例,示例如下:

exp system/oracle@charge TABLE=scott.dept,scott.emp FILE=tab1.dmp

(2)导出方案

导出方案是指使用EXP工具将一个或多个方案中的所有对象记数据存储到OS文件中,导出表是使用OWNER选项来完成的。

普通用户可以导出其自身方案,但如果要导出其他方案,则要求该用户必须具有DBA角色或EXP_FULL_DATABASE角色。当用户要导出其自身方案的所有对象时,可以不指定OWNER选项,下面以SYSTEM用户导出SCOTT方案的所有对象为例,示例如下:

exp system/oracle@charge OWNER=scott FILE=schemal.dmp

以上为命令行方式进行数据的导出,EXP工具还可以以交互的方式进行数据导出。

(1)导出表(交互方式)

[oracle@ora-asm3 dbs]$ exp

Export: Release 10.2.0.1.0 - Production on星期一6月16 16:24:26 2008

Copyright (c) 1982, 2005, Oracle.All rights reserved.

Username: charge输入用户名

Password:输入密码

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

Enter array fetch buffer size: 4096 >输入缓冲区大小,可以默认也可以自定义,如果数据文件较大,建议设置的大一些。

Export file: expdat.dmp > charge01.dmp输入导出的文件名,必须以”.dmp”文件做为扩展名。

(2)U(sers), or (3)T(ables): (2)U > t输入导出类型,默认为用户(也就是方案),在此输入t,为导出表

Export table data (yes/no): yes >是否导出表中的数据,如果选NO,则导出表结构。

Compress extents (yes/no): yes >是否对数据压缩

Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...

Table(T) or Partition(T:P) to be exported: (RETURN to quit) > clients输入表名

开始导出clients表数据

. . exporting tableCLIENTS10 rows exported

Table(T) or Partition(T:P) to be exported: (RETURN to quit) >如果没有要导出的数据时,按回车退出。

Export terminated successfully without warnings.

提示导出成功,没有任何告警。

(2)导出方案(交互方式)

[oracle@ora-asm3 dbs]$ exp

Export: Release 10.2.0.1.0 - Production on星期一6月16 16:23:47 2008

Copyright (c) 1982, 2005, Oracle.All rights reserved.

Username: charge输入用户名

Password:输入密码

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

Enter array fetch buffer size: 4096 >输入缓冲区大小,可以默认也可以自定义,如果数据文件较大,建议设置的大一些。

Export file: expdat.dmp > charge.dmp输入导出的文件名,必须以”.dmp”做为扩展名。

(2)U(sers), or (3)T(ables): (2)U >u输入导出类型,默认为用户(方案),可以直接回车,也可以输入u。

Export grants (yes/no): yes >导入权限

Export table data (yes/no): yes >是否导出表中的数据,如果选NO,则导出表结构。

Compress extents (yes/no): yes >是否对数据压缩

Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

. exporting pre-schema procedural objects and actions

. exporting foreign function library names for user CHARGE

. exporting PUBLIC type synonyms

. exporting private type synonyms

. exporting object type definitions for user CHARGE

About to export CHARGE's objects ...

. exporting database links

. exporting sequence numbers

. exporting cluster definitions

. about to export CHARGE's tables via Conventional Path ...

. . exporting tableBALANCE0 rows exported

. . exporting tableBALANCEFINISHED0 rows exported

………………

. exporting synonyms

. exporting views

. exporting stored procedures

. exporting operators

. exporting referential integrity constraints

. exporting triggers

. exporting indextypes

. exporting bitmap, functional and extensible indexes

. exporting posttables actions

. exporting materialized views

. exporting snapshot logs

. exporting job queues

. exporting refresh groups and children

. exporting dimensions

. exporting post-schema procedural objects and actions

. exporting statistics

Export terminated successfully without warnings.

提示导出成功,没有任何告警。

数据导入工具IMP

(1)导入表

导入表是指使用工具IMP将EXP文件中的表结构及其数据转载到数据库中,导入表是使用TABLES选项来完成的。

普通用户可以直接导入其拥有的表,但如果要将表导入到其他用户中,则要求该用户必须具有IMP_FULL_DATABASE角色或DBA角色。注意,如果要将表导入到其他用户中,则需要指定FROMUSER和TOUSER选项,示例如下:

imp scott/oracle@charge FILE=tab2.dmp TABLES=dept.emp

imp system/oracle@charge FILE=tab2.dmp TABLES=dept.empFROMUSER=scottTOUSER=system

如上所示,第一示例表示将文件tab2.dmp中DEPT和EMP表的结构和数据导入到SCOTT用户中;第二个示例表示文件tab2.dmp中SCOTT用户的DEPT和EMP表导入SYSTEM用户中。

(2)导入方案

导入方案是指使用工具IMP将EXP文件中的特定方案的所有对象及数据转载到数据库中。

普通用户可以直接导入其自身方案,并且在导入时需要提供USERID和FILE选项即可。但如果要将一个方案的所有对象导入到其他方案中,则要求该用户必须具有IMP_FULL_DATABASE角色,并且必须提供FROMUSER和TOUSER选项。示例如下:

imp scott/oracle@charge FILE=schema2.dmp

imp system/oracle@charge FILE=schema2.dmp FROMUSER=scottTOUSER=system

如上所示,第一示例表示将文件schema 2.dmp中SCOTT用户的所有对象及数据导入到SCOTT用户中;第二个示例表示文件schema 2.dmp中SCOTT用户的所有对象及数据导入SYSTEM用户中。

以上为命令行方式进行数据的导出,EXP工具还可以以交互的方式进行数据导出。

(1)导入表(交互方式)

[oracle@ora-asm3 ~]$imp

Import: Release 10.2.0.1.0 - Production on星期一6月16 16:40:10 2008

Copyright (c) 1982, 2005, Oracle.All rights reserved.

Username: charge输入用户名

Password:输入密码

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

Import file: expdat.dmp > charge.dmp输入要导入的数据文件

Enter insert buffer size (minimum is 8192) 30720>输入缓冲区大小,可以默认也可以自定义,如果数据文件较大,建议设置的大一些。

Export file created by EXPORT:V10.02.01 via conventional path

import done in ZHS16GBK character set and AL16UTF16 NCHAR character set

List contents of import file only (yes/no): no >只列出导入文件的内容

Ignore create error due to object existence (yes/no): no >由于对象已存在,忽略创建错误

Import grants (yes/no): yes >导入权限

Import table data (yes/no): yes >导入表数据,如果选NO,则导入表结构

Import entire export file (yes/no): no >导入整个导出文件

Username: charge要导入方案的名称

Enter table(T) or partition(T:P) names. Null list means all tables for user

Enter table(T) or partition(T:P) name or . if done: clients输入要导入的表名

Enter table(T) or partition(T:P) name or . if done:如果没有要导入的表时,直接回车,进行导入

. importing CHARGE's objects into CHARGE

. importing CHARGE's objects into CHARGE

. . importing table"CLIENTS"10 rows imported

Import terminated successfully without warnings.

导入成功,没有告警。

(2)导入方案(交互方式)

[oracle@ora-asm3 ~]$imp

Import: Release 10.2.0.1.0 - Production on星期一6月16 17:17:54 2008

Copyright (c) 1982, 2005, Oracle.All rights reserved.

Username: charge输入用户名称

Password:输入密码

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

Import file: expdat.dmp > charge.dmp输入要导入的数据文件

Enter insert buffer size (minimum is 8192) 30720>输入缓冲区大小,可以默认也可以自定义,如果数据文件较大,建议设置的大一些。

Export file created by EXPORT:V10.02.01 via conventional path

import done in ZHS16GBK character set and AL16UTF16 NCHAR character set

List contents of import file only (yes/no): no >只列出导入文件的内容

Ignore create error due to object existence (yes/no): no >由于对象已存在,忽略创建错误

Import grants (yes/no): yes >导入权限

Import table data (yes/no): yes >导入表数据,如果选NO,则导入表结构

Import entire export file (yes/no): no >导入整个导出文件

Username: charge输入要导入方案的名称

Enter table(T) or partition(T:P) names. Null list means all tables for user

Enter table(T) or partition(T:P) name or . if done:回车,进行导入数据

. importing CHARGE's objects into CHARGE

. . importing table"BALANCE"0 rows imported

. . importing table"BALANCEFINISHED"0 rows imported

About to enable constraints...

Import terminated successfully without warnings.

导入成功,没有任何告警。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值