注释:
相信一些公司习惯将真实的表数据和索引不在一个表空间;
(例如:服务器'编号:59' TEST 用户 T1表数据在 DATA表空间,索引在 IDX表空间)
那怎么实现导到 其他服务器'编号:69' TEST用户 T1表数据在 USERS 表空间,索引在 USER01 表空间;
方案:
1)
手动 其他服务器 TEST用户下创建表和索引分别指向;---表少可以这样做
2)
设置目标 TEST用户 默认表空间 USER01,impdp 时加参数TRANSFORM ,索引 通过 remap_tablespace参数更改到自己想指定的表空间;
3)
是否可以有这样的参数,来实现 如果对象的表空间=data 改成
USER01
,
表空间=ind 改成
USER01
;
|
简单说下2个参数意义:
TARGET_EDITION:用于加载元数据的版本。
TRANSFORM=segment_attributes:n 使用TRANSFORM选项可以完成去掉表空间和存储子句的目的,这样我们便可以控制导入时按照目标默认的参数
REMAP_TABLESPACE:将表空间对象重新映射到另一个表空间。
|
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
Connected as [email protected]/testdb AS SYSDBA
SQL>
SQL> create user test identified by test ;
User created
SQL> grant dba to test;
Grant succeeded
SQL> conn test/[email protected]:1521/testdb
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
Connected as [email protected]:1521/testdb
SQL> create table t1 tablespace FWS_BUSINESS_DATA as select * from sinotest.cs_order ;
Table created
SQL> SELECT TABLE_NAME,TABLESPACE_NAME FROM USER_tables C WHERE C.TABLE_NAME='T1';
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
T1 FWS_BUSINESS_DATA
SQL> create index ind_t1 on T1 (con_id) tablespace FWS_BUSINESS_IDX;
Index created
SQL> SELECT TABLE_NAME,INDEX_NAME,TABLESPACE_NAME FROM USER_INDEXES C WHERE C.TABLE_NAME='T1';
TABLE_NAME INDEX_NAME TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
T1 IND_T1 FWS_BUSINESS_IDX
SQL> SELECT COUNT(1) FROM t1;
COUNT(1)
----------
103402
SQL>
|
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
Connected as [email protected]/testdb AS SYSDBA
SQL> create public database link db_test connect to test identified by test using '(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.59)(PORT = 1521)))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = testdb)))';
Database link created
SQL> 检验dblink是否正常:
SQL> SELECT COUNT(1) FROM t1@db_test;
COUNT(1)
----------
103402
SQL> 由于服务器'编号:69 有test用户' 查看下默认表空间 及 要测试的2个表空间存在情况:
SQL> SELECT username,default_tablespace FROM user_users;
USERNAME DEFAULT_TABLESPACE
------------------------------ ------------------------------
TEST USERS
SQL> select * from v$tablespace s where s.NAME in ('USER01','
USERS
','
FWS_BUSINESS_DATA
','
FWS_BUSINESS_IDX
');
TS# NAME INCLUDED_IN_DATABASE_BACKUP BIGFILE FLASHBACK_ON ENCRYPT_IN_BACKUP
---------- ------------------------------ --------------------------- ------- ------------ -----------------
4 USERS YES
NO
YES
5 USER01 YES NO YES
SQL> 可以看出 69服务器只有users,user01 2个表空间...
|
E:>impdp test/[email protected]:1521/sinodb network_link=db_test tables=test.t1 remap_schema=test:test TRANSFORM=segment_attributes:n remap_tablespace=FWS_BUSINESS_IDX:user01 table_exists_action=replace
Import: Release 10.2.0.1.0 - Production on 星期五, 22 8月, 2014 16:25:26 Copyright (c) 2003, 2005, Oracle. All rights reserved. 连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 启动 "TEST"."SYS_IMPORT_TABLE_01": test/********@192.168.0. 69 :1521/sinodb network_link=db_test tables=test.t1 remap_schema=test:test TRANSFORM=segment_attributes:n remap_tablespace=FWS_BUSINESS_IDX:user01 table_exists_action=replace
正在使用 BLOCKS 方法进行估计... 处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA 使用 BLOCKS 方法的总估计: 32 MB 处理对象类型 TABLE_EXPORT/TABLE/TABLE . . 导入了 "TEST"."T1" 103402 行 处理对象类型 TABLE_EXPORT/TABLE/INDEX/INDEX 处理对象类型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS 作业 "TEST"."SYS_IMPORT_TABLE_01" 已于 16:20:34 成功完成
E:>
--校验...是否按照理想的表空间导入
|
E:\oracle>impdp test/[email protected]:1521/sinodb network_link=db_test tables=test.t1 remap_schema=test:test remap_tablespace=FWS_BUSINESS_DATA:users remap_tablespace=FWS_BUSINESS_IDX:user01 table_exists_action=replace Import: Release 10.2.0.1.0 - Production on 星期五, 22 8月, 2014 17:18:38 Copyright (c) 2003, 2005, Oracle. All rights reserved. 连接到: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options 启动 "TEST"."SYS_IMPORT_TABLE_01": test/********@192.168.0.69:1521/sinodb network_link=db_test tables=test.t1 remap_schema=test:test remap_tablespace=FWS_BUSINESS_DATA:users remap_tablespace=FWS_BUSINESS_IDX:user01 table_exists_action=replace 正在使用 BLOCKS 方法进行估计... 处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA 使用 BLOCKS 方法的总估计: 32 MB 处理对象类型 TABLE_EXPORT/TABLE/TABLE . . 导入了 "TEST"."T1" 103402 行 处理对象类型 TABLE_EXPORT/TABLE/INDEX/INDEX 处理对象类型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS 作业 "TEST"."SYS_IMPORT_TABLE_01" 已于 17:13:45 成功完成 E:\oracle> |
SQL> SELECT TABLE_NAME,TABLESPACE_NAME FROM USER_tables C WHERE C.TABLE_NAME='T1';
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
T1 USERS
SQL> SELECT TABLE_NAME,INDEX_NAME,TABLESPACE_NAME FROM USER_INDEXES C WHERE C.TABLE_NAME='T1';
TABLE_NAME INDEX_NAME TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
T1 IND_T1 USER01
SQL>
|
1) 测试:参数TRANSFORM、remap_tablespace都存在,导入测试 ,看参数生效情况结论:TRANSFORM=segment_attributes:n 参数,导致remap_tablespace参数失效,会导入到用户默认表空间2) 测试:去掉 TRANSFORM=segment_attributes:n 参数后正常测试 remap_tablespace=FWS_BUSINESS_DATA:users users表空间真是存在,看索引FWS_BUSINESS_IDX是否报错?结论:索引报错没有FWS_BUSINESS_IDX表空间,remap_tablespace=FWS_BUSINESS_DATA:user01只生效了表;(正常不过)3) 测试:想将索引转换为users ,设想写为(remap_tablespace=FWS_BUSINESS_DATA:users remap_tablespace=FWS_BUSINESS_idx:user01)是否可以都生效结论:参数都生效了,也就是说它识别成2个参数了,且2个remap_tablespace没有顺序情况;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28602568/viewspace-1256223/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/28602568/viewspace-1256223/