標籤:oracle資料庫遷移
目的:將192.168.9.102上GGWSXT/[email protected]:1521/ORACLE部署到104上
1、查看原使用者資料表空間
select tablespace_name,count(0) from dba_segments where owner=upper(‘GGWSXT‘) group by tablespace_name;
2、查看原使用者建立資料表空間的目錄
select * from dba_data_files;
3、為原使用者建立資料表空間
create tablespace TS_GGWSXT_XT
datafile ‘/步驟2/TS_GGWSXT_XT.bdf‘ size 2048M
AUTOEXTEND ON NEXT 256M MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT auto;
4、建立新使用者
Create user GGWSXT_01
Identified by GGWSXT_01
Default tablespace TS_GGWSXT_XT
Temporary tablespace TEMP
5、為新使用者賦許可權
Grant connect,resource,dba,select any table to GGWSXT_01;
grant read,write on directory dpdir to GGWSXT_01;
select * from dba_directories
6、為原使用者賦目錄許可權
grant read,write on directory dpdir to GGWSXT_01;
7、通過expdp(資料泵方式)匯出原使用者資料 [如果時從11g遷移到10g後面添加 version=10.2.0.1.0低版本] su - oralce 下執行
nohup expdp ggwsxt/[email protected]/oracle schemas=ggwsxt dumpfile=ggwsxt_20150713.dmp DIRECTORY=dpdir &
tail -f nohup.out
8、資料庫不在一台伺服器上,備份檔案目錄不同時;
select * from dba_directories; 查詢匯入匯出dmp檔案的路徑
scp /匯出庫路徑/GGWSXT_20150713.dmp [email protected]:/匯入庫路徑/GGWSXT_20150713.dmp
9、chown oralce.oinstall(或者是dba) GGWSXT_20150713.dmp
10、通過impdp將資料匯入新使用者,語句中間無換行
nohup impdp GGWSXT_01/[email protected]/ORACLE directory=dpdir dumpfile=GGWSXT_20150713.dmp remap_schema=GGWSXT:GGWSXT01 remap_tablespace=原使用者資料表空間名:新使用者資料表空間名,原使用者資料表空間名:新使用者資料表空間名 &
(注釋:資料表空間名查詢方式select tablespace_name,count(0) from dba_segments where owner=upper(‘使用者名稱‘) group by tablespace_name;)
11、資料匯入後,需執行一下語句以實現使用者物件的重新編譯 在plsql中
execute dbms_utility.compile_schema(upper(‘新使用者名稱GGWSXT_01‘));
註:11.5:若匯入的是兩個有關聯的庫,請匯入之後更新新使用者同義字
本文出自 “學習感悟” 部落格,請務必保留此出處http://10183596.blog.51cto.com/10173596/1673821
oracle資料庫遷移的步驟