使用exp/imp传输表空间(Oracle)

有时候,可以使用exp将以传输表空间的方式将其导出,传输表空间是一种机制,用来把一个数据库上的格式数据文件附加到另一个数据库。

  需要注意:
  对于导出文件dmp来说,Oracle实现了跨平台的处理,即在任何一个可运行的平台上,都能使用imp将其导入,但是对于表空间所包含的数据文件而言,各个平台上是不一样的,包含不能通过简单的复制来处理。数据文件不是独立于OS的。
  传输表空间移动数据速度非常快。
  使用前提:
  1.源和目标数据库使用相同的字符集。
  2.目标数据库不能有和源表空间相同的表空间
  3.源和目标数据库拥有相同的块大小
  4.必须传输自包含的对象集
  5.源和目标数据库运行的硬件平台必须相同

  这里以linux下Oracle9.2.0.4为例,简要介绍一下使用:
  1. 创建表空间,并生成数据
  sqlplus "/ as sysdba"
  create tablespace hexiong datafile ?/hexiong.dbf size 1M;
  create user hexiong identified by hexiong default tablespace hexiong;
  grant connect, resource to hexiong;
  conn hexiong/hexiong
  create table t as select * from all_objects;
   2.检查一下表空间是否齐备:
  exec sys.dbms_tts.transport_set_check('hexiong', TRUE);
  PL/SQL procedure successfully completed.
  SQL> select * from sys.transport_set_violations;
  no rows selected
  这表示该表空里的对象集是自包含的(对象及其索引都在此表空间中)
  3.设定表空间为只读
  alter tablespace hexiong read only;
  4.开始exp

SQL> host exp userid=/'sys/change_on_install as sysdba/' transport_tablespace=y tablespaces=(hexiong) file=/u01/app/oracle/exphexiong.dmp

Export: Release 9.2.0.4.0 - Production on ÐÇÆÚÈÕ 7ÔÂ 30 19:27:00 2006

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to: Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set
Note: table data (rows) will not be exported
About to export transportable tablespace metadata...
For tablespace HEXIONG ...
. exporting cluster definitions
. exporting table definitions
. . exporting table                              T
. exporting referential integrity constraints
. exporting triggers
. end transportable tablespace metadata export
Export terminated successfully without warnings.

  5. 将导出的文件以及相关源表空间的数据文件拷到目标数据库或机器上
  导出文件:/u01/app/oracle/exphexiong.dmp
  数据文件:
SQL> select b.name from v$tablespace a, v$datafile b where a.ts#=b.ts# and a.name='HEXIONG';

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/bjlnx1/hexiong.dbf

  6.进入目标机器上,创建对应表空间的用户,不必指定缺省表空间
  设exphexiong.dmp以及hexiong.dbf的位置都在/home/oradba上
  cd /home/oradba
  SQL>create user hexiong identified by hexiong;
  7.导入:
   imp file=exphexiong.dmp userid=/'sys/change_on_install as sysdba/' transport_tablespace=y datafiles=/home/oradba/hexiong.dbf
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

iihero

谢谢打赏,不断前行

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值