ITPub博客

首页 > 数据库 > Oracle > 可传输表空间记载

可传输表空间记载

原创 Oracle 作者:dotaddjj 时间:2011-11-02 22:32:58 0 删除 编辑

今天泡pub看到一个网友说到跨平台迁移表空间,把a库的表空间迁移到b库中,往常的可以通过exp和imp或者数据磊工具导入导出,记得在oracle concepts中提到了关于可传输表空间的功能,在oracle 10G中可以跨平台迁移。

这里假设a库是源库,b库是目标库

select a.platform_name,b.endian_format from v$database a,v$transportable_platform b

where a.platform_name=b.platform_name

platform_name endian_format

分别在a库和b库这里主要是查看数据库所在的服务器的os上的信息。

在oracle 10g的视图

Select platform_id,platform_name,endian_format from v$transportable_platform

1 Solaris[tm] OE (32-bit) Big

2 Solaris[tm] OE (64-bit) Big

7 Microsoft Windows IA (32-bit) Little

10 Linux IA (32-bit) Little

6 AIX-Based Systems (64-bit) Big

。。。。。

列出的支持迁移的os版本,其中如果涉及到a库和b库的endian_format不同需要用rman做转换。

A库在表空间example上创建test_trans表

Create user test identified by test default tablespace example

Create table test.TEST_TRANS tablespace example

As select * from dba_users

导出前alter tablespace example read only不然等下会报错的。

用exp导出

Exp ‘”sys/oracle@orcl as sysdba”’ file=d:test.dmp transport_tablespace=y log=d:test.log

这里导出的并不是表空间中所有数据信息,只是导出了example的元数据,至于元数据个人就是理解成example的包含用户数据的数据信息,类似于数据字典的,所以这个dmp文件会很小。

由于个人是测试库都是windows 32bit little,但是实际在生产中可能更多是不同平台,不同字节顺序的。用rman convert一下即可,这里也体现了rman的扩平台迁移的功能强大性!

A库

Rman target /

Rman>convert tablespace example to platform ‘'Microsoft Windows IA (32-bit)’

Format ‘/tmp/oracle/%u’;

利用chmod修改一下文件的权限,不然等下cp过去了无法使用。

利用ftp或者ssh等工具cp A库中的example表空间的example01.dbf和刚刚生成的元数据文件.

B库

Imp ‘”sys/oracle as sysdba”’ file=e:/test.dmp datafiles=’e:oracleproduct10.2.0oradataorclexample01.dbf’

如果是数据磊请参照相应参数修改为dumpfile logfile transport_datafiles等

可能导入时会出现用户不存在的错误,因为在原来的example表空间中存在user test信息,但是实际在B库中可能不存在user test,这里我们只需要在B库中创建指定的user然后授予及基本的connect,resource权限,然后再次导入。

导入完成后别忘把B库的表空间example

Alter tablespace example read write

不然数据就插不进去了!

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25362835/viewspace-1056109/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 性能调整篇01
请登录后发表评论 登录
全部评论
  • 博文量
    220
  • 访问量
    1662983