本文將介紹Oracle跨平臺(tái)遷移,比如從Oracle跨平臺(tái)遷移到其他類型的數(shù)據(jù)庫(kù),但是保留原有結(jié)構(gòu)。這樣也能減輕DBA的很多工作負(fù)擔(dān)。希望本文能幫助大家更好的理解Oracle跨平臺(tái)遷移。
1、在原庫(kù)中導(dǎo)出相關(guān)信息:
expdp system/sywg1234 directory=test dumpfile=test.dump logfile=test.log schemas=SYWG,GAZX,WEBCALL,HQ,SJCK,SJPZ CONTENT=METADATA_ONLY 2、去原庫(kù)的表空間信息:
去TOAD導(dǎo)出表空間信息,后編輯導(dǎo)出腳本,將系統(tǒng)相關(guān)的信息刪除;將目錄及文件大小按實(shí)際需要更改.
3、到目的庫(kù)中操作:
將原庫(kù)中導(dǎo)出的dump文件,CP到目的庫(kù)中一個(gè)目錄下;
創(chuàng)建導(dǎo)入目錄;
impdp system/sywg1234 directory=test dumpfile=test.dump logfile=test_imp.log CONTENT=METADATA_ONLY exclude=statistc 注:
此時(shí)有一個(gè)很大的問(wèn)題,就是即使導(dǎo)入的是表結(jié)構(gòu),無(wú)數(shù)據(jù),但還是占用大量的表空間,這確實(shí)是一個(gè)比較大的問(wèn)題
4、到目的庫(kù)導(dǎo)入后,分析所有表:
--生成統(tǒng)計(jì)信息分析腳本:
select 'analyze table '||owner||'.'||table_name ||' compute statistics; 'from all_tables where OWNER in ('GAZX','SJCK','SJPZ','SYWG','HQ','WEBCALL') ---執(zhí)行上面生成的腳本,以進(jìn)行統(tǒng)計(jì)信息的更新
5、壓縮空表占用的大量表空間:
---查看表的占用空間情況,
SELECT OWNER,segment_name,SEGMENT_TYPE,BYTES/1024/1024 FROM DBA_SEGMENTS WHERE OWNER='GAZX' ORDER BY 4 DESC ---確認(rèn)表中是否有數(shù)據(jù)
SELECT * FROM GAZX.GSGG ---查看表是否允許row_movement
select a.row_movement,a.* from all_tables a where a.owner='GAZX' AND a.TABLE_NAME='GSGG' ---若不允許,則開(kāi)啟row_movement
alter table GAZX.GSGG enable row movement; 生成批量處理的腳本:
SELECT 'ALTER TABLE GAZX.'||SEGMENT_NAME||' enable row movement;' FROM DBA_SEGMENTS WHERE OWNER='GAZX' AND SEGMENT_TYPE='TABLE' ----壓縮表占用的空間
ALTER TABLE GAZX.GSGG SHRINK SPACE CASCADE; 生成批量處理的腳本:
SELECT 'ALTER TABLE GAZX.'||SEGMENT_NAME||' SHRINK SPACE CASCADE;' FROM DBA_SEGMENTS WHERE OWNER='GAZX' AND SEGMENT_TYPE='TABLE' ----壓縮表完畢后,壓縮數(shù)據(jù)文件
6、原庫(kù)和目的庫(kù)的校對(duì):
導(dǎo)入后校對(duì):
---核對(duì)表的數(shù)量
select OWNER,COUNT(TABLE_NAME) from all_tables where OWNER in ('GAZX','SJCK','SJPZ','SYWG','HQ','WEBCALL') GROUP BY OWNER ---核對(duì)索引的數(shù)量
SELECT OWNER,COUNT(TABLE_NAME) FROM ALL_INDEXES where OWNER in ('GAZX','SJCK','SJPZ','SYWG','HQ','WEBCALL') GROUP BY OWNER