帮一个朋友解决表空间传输做一个实验及总结

SQL> connect sys/oracle@primary as sysdba
已连接。
SQL> create tablespace testimp
2 datafile '/home/oracle/oracle/product/10.2.0/oradata/orcl/testimp.dbf' size 10M;

表空间已创建。

SQL> create user testimp identified by testimp default tablespace testimp temporary tablespace temp;

用户已创建。

SQL> grant connect,resource to testimp;

授权成功。

SQL> connect testimp/testimp
ERROR:
ORA-01017: invalid username/password; logon denied


警告: 您不再连接到 ORACLE。
SQL> connect testimp/testimp@primary
已连接。
SQL> create table testimp(id number,name varchar2(20));

表已创建。

SQL> insert into testimp values(1,'testimp');

已创建 1 行。

SQL> /

已创建 1 行。

SQL> /

已创建 1 行。

SQL> commit;

提交完成。

SQL> exec dbms_tts.transport_set_check('testimp',true);
BEGIN dbms_tts.transport_set_check('testimp',true); END;

*
第 1 行出现错误:
ORA-06550: 第 1 行, 第 7 列:
PLS-00201: 必须声明标识符 'DBMS_TTS.TRANSPORT_SET_CHECK'
ORA-06550: 第 1 行, 第 7 列:
PL/SQL: Statement ignored


SQL> connect sys/oracle@primary as sysdba
已连接。
SQL> exec dbms_tts.transport_set_check('testimp',true);

PL/SQL 过程已成功完成。

SQL> select * from transport_set_violations;

未选定行

SQL> alter tablespace testimp read only;

表空间已更改。

SQL> host
[oracle@primary test]$ exit
exit

SQL> select file_name,tablespace_name from dba_data_files where tablespace_name='TESTIMP';

FILE_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME
------------------------------
/home/oracle/oracle/product/10.2.0/oradata/orcl/testimp.dbf
TESTIMP


SQL> host
[oracle@primary test]$ exp transport_tablespace=y tablespaces=testimp file=testimp.dmp

Export: Release 10.2.0.3.0 - Production on 星期四 2月 8 05:24:14 2007

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


用户名: sys/oracle@primary as sysdba

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options
已导出 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集
注: 将不导出表数据 (行)
即将导出可传输的表空间元数据...
对于表空间 TESTIMP...
. 正在导出簇定义
. 正在导出表定义
. . 正在导出表 TESTIMP
. 正在导出引用完整性约束条件
. 正在导出触发器
. 结束导出可传输的表空间元数据
成功终止导出, 没有出现警告。
[oracle@primary test]$ ls
afiedt.buf control02.ctl perfstat.dbf redo02.log rmorcl01.dgf system01.dbf testimp.dmp users01.dbf
control01.ctl control03.ctl redo01.log redo03.log sysaux01.dbf temp01.dbf undotbs01.dbf
[oracle@primary test]$ cp /home/oracle/oracle/product/10.2.0/oradata/orcl/testimp.dbf .
[oracle@primary test]$ exit
exit

SQL> connect sys/oracle@test as sysdba
已连接。
SQL> create user testimp identified by testimp;

用户已创建。

SQL> grant connect,resource to testimp;

授权成功。

SQL> host
[oracle@primary test]$ imp transport_tablespace=y datafiles='/home/oracle/oracle/oradata/test/testimp.dbf' tablespaces=testimp file=testimp.dmp

Import: Release 10.2.0.3.0 - Production on 星期四 2月 8 05:29:46 2007

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

用户名: sys/oracle@test as sysdba

连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options

经由常规路径由 EXPORT:V10.02.01 创建的导出文件
即将导入可传输的表空间元数据...
已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入
. 正在将 SYS 的对象导入到 SYS
. 正在将 SYS 的对象导入到 SYS
. 正在将 TESTIMP 的对象导入到 TESTIMP
. . 正在导入表 "TESTIMP"
. 正在将 SYS 的对象导入到 SYS
成功终止导入, 没有出现警告。
[oracle@primary test]$ exit
exit

SQL> select name from v$database;

NAME
---------
TEST

SQL> connect testimp/testimp@test;
已连接。
SQL> select * from testimp;

ID NAME
---------- --------------------
1 testimp
1 testimp
1 testimp

SQL> connect sys/oracle@primary as sysdba
已连接。
SQL> alter tablespace testimp read write;

表空间已更改。

SQL>alter user testimp default tablespace testimp;

用户已更改

张兄以上是我做的实验结果,没有问题的,我大体总结一下吧:
1、检验表空间自包含性
exec dbms_tts.transport_set_check('testimp',true);
查询transport_set_violations确认该表空间的自包含性
select * from transport_set_violations;
如果没有查询结果,则说明该表空间是可以传输的,否则,是需要处理后,才能传输的.
2、将表空间设置为只读
alter tablespace testimp read only;
设置为只读以防止在移动期间表空间数据发生改变。
3、使用exp卸出表空间
$exp transport_tablespace=y tablespaces=testimp file=testimp.dmp
用户名:sys/oracle@primary as sysdba
注:如果是跨平台传输,需要用Rman做一下转换,可以先进行查询
select d.platform_name,endian_format from v$transportable_platform tp,v$database d
where tp.platform_name=d.platform_name;
$rman target sys/oracle
RMAN>convert tablespace testimp to platform 'Microsoft Windows IA (32-bit)' format '/share/%U';
4、复制数据文件及卸出文件
将这个表空间下的所有数据文件及卸出文件复制到另一个服务器上。
5、在另一个服务器建同卸出库一样的用户。
6、使用imp装入表空间
$imp transport_tablespace=y datafiles='/home/oracle/oracle/oradata/test/testimp.dbf'
tablespaces=testimp file=testimp.dmp
用户名:sys/oracle@test as sysdba
7、将表空间修改为读写状态
alter tablespace testimp read write;
8、导入库用户重新指定默认表空间
alter user testimp default tablespace testimp;
注:1、exp,imp必顺都具有sysdba权限的帐号,如默认sys用户就是
2、如果一个表空间下有多个数据文件,必须都要拷贝后,指定导入.
3、两边库都必须具体相同的这个表空间下对象所属的用户.如:这个表空间下所有对象所属用户为testimp,导入库中必须存在testimp用户.
4、导入库不能存在和传输表空间相同名称的表空间.

[@more@]

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

转载于:http://blog.itpub.net/40976/viewspace-899731/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值