詳細(xì)的執(zhí)行步驟:
1.ltdb導(dǎo)出可傳輸表空間(以sysdba執(zhí)行導(dǎo)出)到dmp文件。
2.將ltdb的tsts表空間改為只讀。
3.用操作系統(tǒng)命令復(fù)制數(shù)據(jù)文件和dmp文件到另一個位置給另一個數(shù)據(jù)庫epras使用。
如果在一臺服務(wù)器上,dmp文件可以不必復(fù)制,復(fù)制完成后,將ltdb的tsts表空間改為可讀寫。
4.在epras數(shù)據(jù)庫創(chuàng)建ts用戶(此時不必授權(quán))。
5.導(dǎo)入可傳輸表空間(以sysdba執(zhí)行導(dǎo)入)到dmp文件到epras數(shù)據(jù)庫。
6.將epras的tsts表空間改為可讀寫,給ts用戶授權(quán)。
好處很明顯,和數(shù)據(jù)exp/imp相比,速度很快,dmp文件只包含表空間元數(shù)據(jù)10g支持不同平臺的表空間傳輸,支持大頭/小頭操作系統(tǒng)之間的傳輸/*
在Oracle以前的版本中,可傳輸?shù)谋砜臻g的特性可以讓表空間在相同的體系結(jié)構(gòu)和操作系統(tǒng)之間遷移.
在 Oracle 數(shù)據(jù)庫 10g 中,這個局限消失了:只要操作系統(tǒng)字節(jié)順序相同,您就可以在平臺
之間傳輸表空間。一些操作系統(tǒng)(包括 Windows)在低位內(nèi)存地址中用最低有效字節(jié)存儲
多字節(jié)二進制數(shù)據(jù);因此這種系統(tǒng)被稱為低地址低字節(jié)序。相反,其它的操作系統(tǒng)
(包括 Solaris)將最高有效字節(jié)存儲在低位內(nèi)存地址中,因此這種系統(tǒng)被稱為低地址高字節(jié)序。
當(dāng)一個低地址高字節(jié)序的系統(tǒng)試圖從一個低地址低字節(jié)序的系統(tǒng)中讀取數(shù)據(jù)時,需要一個轉(zhuǎn)換過程
— 否則,字節(jié)順序?qū)?dǎo)致不能正確解釋讀取的數(shù)據(jù)。
不過,當(dāng)在相同字節(jié)順序的平臺之間傳輸表空間時,不需要任何轉(zhuǎn)換。
Oracle 10g的表空間跨平臺遷移,與Oracle9i比較就是增加了一個使用Rman進行的文件格式轉(zhuǎn)換的過程。
實際上僅僅是轉(zhuǎn)換了數(shù)據(jù)文件頭的格式信息。
COLUMN PLATFORM_NAME FORMAT A30
檢查可轉(zhuǎn)換平臺
SELECT * FROM V$TRANSPORTABLE_PLATFORM;
PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
----------- ---------------------------------------- --------------
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
3 HP-UX (64-bit) Big
5 HP Tru64 UNIX Little
4 HP-UX IA (64-bit) Big
11 Linux IA (64-bit) Little
15 HP Open VMS Little
8 Microsoft Windows IA (64-bit) Little
9 IBM zSeries Based Linux Big
13 Linux 64-bit for AMD Little
16 Apple Mac OS Big
12 Microsoft Windows 64-bit for AMD Little
17 Solaris Operating System (x86) Little
18 IBM Power Based Linux Big
17 rows selected
檢查源平臺
SELECT d.PLATFORM_NAME, ENDIAN_FORMAT
FROM V$TRANSPORTABLE_PLATFORM tp, V$DATABASE d
WHERE tp.PLATFORM_NAME = d.PLATFORM_NAME;
PLATFORM_NAME ENDIAN_FORMAT
---------------------------------------- --------------
Solaris[tm] OE (64-bit) Big
檢查目標(biāo)平臺
SELECT d.PLATFORM_NAME, ENDIAN_FORMAT
FROM V$TRANSPORTABLE_PLATFORM tp, V$DATABASE d
WHERE tp.PLATFORM_NAME = d.PLATFORM_NAME;
PLATFORM_NAME ENDIAN_FORMAT
------------------------------ -------------
Microsoft Windows IA (32-bit) Little
檢查待轉(zhuǎn)換表空間
EXECUTE DBMS_TTS.TRANSPORT_SET_CHECK('tswin1,tswin2', TRUE);
PL/SQL procedure successfully completed.
是否有沖突
SELECT * FROM TRANSPORT_SET_VIOLATIONS;
no rows selected
運行rman
rman TARGET /
CONVERT TABLESPACE tswin1,tswin2
TO PLATFORM 'Microsoft Windows IA (32-bit)'
FORMAT '/tmp/rman/%U';
在以上的例子中,轉(zhuǎn)換后的文件名難于辨認(rèn)并很難與原始文件關(guān)聯(lián)還可以使用其它格式來為數(shù)據(jù)文件命名。
CONVERT TABLESPACE tswin1,tswin2
TO PLATFORM 'Microsoft Windows IA (32-bit)'
db_file_name_convert '/tmp/LTDB','/tmp/rman'
此處將在轉(zhuǎn)換后保留文件名。
*/
======詳細(xì)執(zhí)行結(jié)果===============
1.ltdb導(dǎo)出
root@t2000 # su - oracle
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
$ ORACLE_SID=LTDB
$ export ORACLE_SID
$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 15 15:54:18 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected.
SQL> create tablespace TSTS datafile '/tmp/LTDB/TSTS01.DBF' size 10M ,'/tmp/LTDB/TSTS02.DBF' size 10M;
Tablespace created.
SQL> create user ts identified by ts default tablespace tsts;
User created.
SQL> grant connect to ts;
Grant succeeded.
SQL> grant resource to ts;
Grant succeeded.
SQL> conn ts/ts
Connected.
SQL> create table t1(c1 varchar(255),c2 varchar(255));
Table created.
SQL> insert into t1 select sys_guid(),sys_guid() from dual connect by level <=10000;
10000 rows created.
SQL> commit;
Commit complete.
SQL> select * from t1 where rownum<=5;
C1 C2
-------------------------------- --------------------------------
163FD8C45C092993E04400144F025BB6 163FD8C45C0A2993E04400144F025BB6
163FD8C45C0B2993E04400144F025BB6 163FD8C45C0C2993E04400144F025BB6
163FD8C45C0D2993E04400144F025BB6 163FD8C45C0E2993E04400144F025BB6
163FD8C45C0F2993E04400144F025BB6 163FD8C45C102993E04400144F025BB6
163FD8C45C112993E04400144F025BB6 163FD8C45C122993E04400144F025BB6
SQL> conn system/sys
Connected.
SQL> alter tablespace tsts read only
SQL> /
Tablespace altered.
SQL> ho
$ exp userid=/'sys/sys as sysdba/' tablespaces=tsts file=/tmp/tsts.dmp l transport_tablespace=y
Export: Release 10.2.0.1.0 - Production on Thu Jun 15 16:20:29 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
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 TSTS ...
. exporting cluster definitions
. exporting table definitions
. . exporting table
. exporting referential integrity constraints
. exporting triggers
. end transportable tablespace metadata export
Export terminated successfully without warnings.
2.epras導(dǎo)入
=============================================
root@t2000 # su - oracle
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 15 16:26:11 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected.
SQL> ho
復(fù)制數(shù)據(jù)文件,此時數(shù)據(jù)庫ltdb的tsts表空間還是read only
$ cp /tmp/LTDB/TS*DBF /oracle
建立目標(biāo)數(shù)據(jù)庫上的用戶,如果不建立,導(dǎo)入時需要加touser=參數(shù),否則會出錯
SQL> create user ts identified by ts;
User created.
SQL> ho
SQL> revoke connect from ts;
Revoke succeeded.
SQL> revoke resource from ts;
Revoke succeeded.
SQL> ho
$ imp userid=/'sys/sys as sysdba/' tablespaces=tsts file=/tmp/tsts.dmp transport_tablespace=y datafiles=/oracle/TSTS01.DBF, /oracle/TSTS02.DBF
Import: Release 10.2.0.1.0 - Production on Thu Jun 15 18:24:06 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
Export file created by EXPORT:V10.02.01 via conventional path
About to import transportable tablespace(s) metadata...
import done in ZHS16GBK character set and AL16UTF16 NCHAR character set
. importing SYS's objects into SYS
. importing SYS's objects into SYS
. importing TS's objects into TS
. . importing table "T1"
. importing SYS's objects into SYS
Import terminated successfully without warnings.
$ exit
SQL> alter tablespace tsts read write;
Tablespace altered.
SQL> select table_name from all_tables where owner='TS';
TABLE_NAME
------------------------------
T1
SQL> grant connect to TS;
Grant succeeded.
SQL> grant resource to TS;
Grant succeeded.
SQL> conn ts/ts
Connected.
SQL> set lines 132
SQL> set pages 9999
SQL> col c1 format a40
SQL> col c2 format a40
SQL> select * from t1 where rownum<=5;
C1 C2
---------------------------------------- ----------------------------------------
163FD8C45C092993E04400144F025BB6 163FD8C45C0A2993E04400144F025BB6
163FD8C45C0B2993E04400144F025BB6 163FD8C45C0C2993E04400144F025BB6
163FD8C45C0D2993E04400144F025BB6 163FD8C45C0E2993E04400144F025BB6
163FD8C45C0F2993E04400144F025BB6 163FD8C45C102993E04400144F025BB6
163FD8C45C112993E04400144F025BB6 163FD8C45C122993E04400144F025BB6
SQL>
新聞熱點
疑難解答
圖片精選