本文是通過exp/imp方式實作,需要将資料庫表空間處于隻讀模式,對于實時應用的生産資料庫,可以采用rman方式進行傳輸表空間,本文源與目标資料庫均為oralce 10.2.0.5 for linux版本。
執行表空間傳輸有以下限制條件:
(1)源資料庫和目标資料庫必須處于相同的平台,10g以後可以用RMAN指令修改資料檔案實作跨平台移動表空間。
(2)對于源資料庫和目标資料庫版本不同時,源資料庫的版本必須低于目标資料庫。
(3)兩邊資料庫字元集和國家字元集必須一緻。
(4)目标資料庫不能存在同名的表空間。
SQL> col PLATFORM_NAME for a40;
SQL> select * from v$transportable_platform order by 3;
PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
----------- ---------------------------------------- --------------
6 AIX-Based Systems (64-bit) Big
18 IBM Power Based Linux Big
2 Solaris[tm] OE (64-bit) Big
4 HP-UX IA (64-bit) Big
16 Apple Mac OS Big
1 Solaris[tm] OE (32-bit) Big
9 IBM zSeries Based Linux Big
3 HP-UX (64-bit) Big
17 Solaris Operating System (x86) Little
20 Solaris Operating System (x86-64) Little
12 Microsoft Windows x86 64-bit Little
13 Linux x86 64-bit Little
8 Microsoft Windows IA (64-bit) Little
19 HP IA Open VMS Little
11 Linux IA (64-bit) Little
5 HP Tru64 UNIX Little
10 Linux IA (32-bit) Little
7 Microsoft Windows IA (32-bit) Little
15 HP Open VMS Little
SQL> create tablespace tjoa datafile '/u01/app/oracle/oradata/orcl/tjoa.dbf' size 10m autoextend on next 10m;
SQL> create user abc identified by abc default tablespace TJOA;
SQL> grant connect,resource to abc;
SQL> conn abc/abc
SQL> create table t as select * from all_objects;
SQL> conn / as sysdba
SQL> execute dbms_tts.transport_set_check(ts_list=>'TJOA',incl_constraints=>TRUE);
SQL> select * from transport_set_violations;
SQL> alter tablespace TJOA read only;
SQL> select tablespace_name, status from dba_tablespaces where tablespace_name = 'TJOA';
TABLESPACE_NAME STATUS
------------------------------ ---------
TJOA READ ONLY
SQL>
exp \'/ as sysdba \' file=tjoa.dmp transport_tablespace=y tablespaces=TJOA buffer=10240000
通過expdp方式:
expdp \'/ as sysdba \' dumpfile=tjoa.dmp directory=dump_dir transport_tablespaces=TJOA
SQL> alter tablespace TJOA read write;
windows/linux平台位元組序同為Little都不需要轉換,10g及以上版本的資料檔案可以直接拷貝。
使用rman的convert指令轉換檔案示例如下:
$ rman target /
RMAN> convert tablespace TJOA to platform 'Linux IA (32-bit)' format '/u01/%U';
scp tjoa.dmp 192.168.233.160:/home/oracle
scp tjoa.dbf 192.168.233.160:/u01/app/oracle/oradata/orcl/
SQL> create user abc identified by abc;
SQL> grant connect,resource to abc;
imp \'/ as sysdba \' file=tjoa.dmp transport_tablespace=y tablespaces=TJOA datafiles=/u01/app/oracle/oradata/orcl/tjoa.dbf
通過impdp方式:
impdp \'/ as sysdba \' dumpfile=tjoa.dmp directory=dump_dir transport_datafiles=/u01/app/oracle/oradata/orcl/tjoa.dbf remap_schema=tjoa:tjoa
SQL> alter user abc default tablespace TJOA;
SQL> select tablespace_name, status from dba_tablespaces where tablespace_name = 'TJOA';
SQL> conn / as sysdba;
Connected.
SQL> alter user abc default tablespace TJOA;
User altered.
SQL>
SQL>
Tablespace altered.
TJOA ONLINE
本文轉自 koumm 51CTO部落格,原文連結:http://blog.51cto.com/koumm/1574822,如需轉載請自行聯系原作者