Oracle11g數據庫遷移到Oracle12C的PDB(使用impdp/expdp)
alter pluggable database hrdb close immediate;
DROP PLUGGABLE DATABASE hrdb INCLUDING DATAFILES;
--1、數據備份
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;
---2、數據導入Oracle12C
--登陸cpcdb
$sqlplus sys/Oracleedw13@192.168.2.218: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 admin@hrdb 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參數就會失效,就會倒進用戶默認的表空間,
sql