標籤:oracle12c 資料移轉 expdp impdp pdb
Oracle11g資料庫遷移到Oracle12C的PDB(使用impdp/expdp)
alter pluggable database hrdb close immediate;
DROP PLUGGABLE DATABASE hrdb INCLUDING DATAFILES;
--一、資料備份
mkdir /oradata/dumpdir
--建立目錄
create or replace directory exp_dir as '/oradata/dumpdir';
--授權
grant read,write on directory exp_dir to hradm;
--查詢
select * from dba_directories;
expdp admin/admin file=hr.dmp directory=exp_dir schemas=hradm;
--刪除
drop directory exp_dir;
---二、資料匯入Oracle12C
--登入cpcdb
$sqlplus sys/[email protected]:1531/hrdb as sysdba
--建立目錄
create or replace directory exp_dir as '/oradata/dumpdir';
--授權
grant read,write on directory exp_dir to hradm;
--查詢
select * from dba_directories;
--建立tbscpc資料表空間
create tablespace tbshr
datafile '/oradata/edw/hrdb/hrdb-001.dbf'
size 2G
autoextend on
next 64m maxsize 20G
segment space management auto
extent management local;
alter tablespace tbshr
add datafile '/oradata/edw/hrdb/hrdb-002.dbf' size 2G
autoextend on
next 50m maxsize 20G;
alter tablespace tbshr
add datafile '/oradata/edw/hrdb/hrdb-003.dbf' size 2G
autoextend on
next 50m maxsize 20G;
--給cpcadm和admin授權,並修改預設資料表空間
grant dba,resource to hradm;
select * from dba_users where username='HRADM';
alter user hradm default tablespace tbshr;
alter database default tablespace tbshr;
create user admin identified by admin;
grant connect,dba to admin;
--使用impdp匯入hrdb資料
impdp [email protected] directory=exp_dir dumpfile=hr20180401004000.DMP remap_tablespace=tbs_hr:tbshr remap_schema=hr:hradm schemas=hr table_exists_action=replace transform=segment_attributes:n
remap_tablespace=tbs_hr:tbshr 原來資料表空間:新的資料表空間
remap_schema=hr:hradm 原來的schema:現在的schema
transform=segment_attributes:n 去掉資料表空間和儲存子句,加上這個參數後,remap_tablesapce參數就會失效,就會倒進使用者預設的資料表空間,
Oracle11g資料庫遷移到Oracle12C的PDB(使用impdp/expdp)