Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1276478
  • 博文数量: 185
  • 博客积分: 50
  • 博客等级: 民兵
  • 技术积分: 3934
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-11 13:11
个人简介

iihero@ChinaUnix, ehero.[iihero] 数据库技术的痴迷爱好者. 您可以通过iihero AT qq.com联系到我 以下是我的三本图书: Sybase ASE in Action, Oracle Spatial及OCI高级编程, Java2网络协议内幕

文章分类

全部博文(185)

文章存档

2014年(4)

2013年(181)

分类: Oracle

2013-07-17 14:33:39

有时候,可以使用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
阅读(1746) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~