1. 程式人生 > >linux測試系統使用expdp遷移資料到windos系統,11.2.0.4版本測試

linux測試系統使用expdp遷移資料到windos系統,11.2.0.4版本測試

測試,使用linux 系統,遷移至windos測試系統,遷移使用者scott

 

1.源端匯出(linux)

2.傳輸

3.目標端匯入(windows)

 

 

1.源端匯出,本次使用expdp

 

1)建立作業系統轉儲目錄,存放expdp匯出的dump檔案

[[email protected] ~]$ cd /picclife/software/dump/

[[email protected] dump]$ ls -lrt /picclife/software/|grep dump
drwxr-xr-x 2 oracle oinstall 4096 Jan 12 09:02 dump

2)查詢or建立資料庫轉儲目錄

SQL> select * from dba_directories;

SQL> create directory scott_dump as '/picclife/software/dump';

Directory created.

授予許可權

SQL> grant read,write on directory scott_dump to scott;

Grant succeeded.

3)作業系統oracle使用者使用遷移使用者進行匯出

expdp scott/tiger DIRECTORY=scott_dump dumpfile=scott_dump%U logfile=expdp_dump schemas=scott

 

2.檔案傳輸

D:\tmp

scott_dump01.dmp

 

3.目標端匯入windows系統

1)測試環境,刪除使用者

SQL> drop user scott cascade;

2)建立表空間

查詢資料檔案目錄

SQL> select name from v$datafile;

根據源端scott使用者,使用的表空間進行建立

SQL> create tablespace test datafile 'C:\WIN_ORACLE_11_DATABASE\APP\ORADATA\WIN11\test01.dbf' size 1m;

表空間已建立。

linux系統,查詢遷移使用者之前的表空間

SQL> select username,DEFAULT_TABLESPACE from dba_users where username='SCOTT';

USERNAME DEFAULT_TABLESPACE
-------------------- --------------------
SCOTT test

 

3)建立使用者

*注意,遷移新環境的使用者預設表空間需要與生產環境中的保持一致,本次查詢上述是test

SQL> create user scott identified by tiger default tablespace test;

 

4)建立轉儲目錄,並授予許可權

SQL> create directory imp_scott as 'D:\tmp';

SQL>  grant read,write on directory imp_scott to scott;

 

5)許可權同步

匯入資料前,需要一些許可權,因此在源端linux查詢相應許可權後,目標端windows進行同步

linux查詢

select * from dba_role_privs where grantee='SCOTT'

GRANTEE GRANTED_ROLE ADMIN_ DEFAUL
-------------------- -------------------- ------ ------
SCOTT RESOURCE NO YES
SCOTT CONNECT NO YES

select * from dba_sys_privs where grantee='SCOTT'

GRANTEE PRIVILEGE ADMIN_
-------------------- -------------------- ------
SCOTT UNLIMITED TABLESPACE NO

*由於只是匯入一個使用者,因此無需同步其它使用者的物件許可權

windows授予

SQL> grant connect,resource to scott;

SQL> grant unlimited tablespace to scott;

 

5)進行匯入

C:\Users\Thinkpad>impdp scott/tiger directory=imp_scott dumpfile=scott_dump%U logfile=scott_impdp