适用场景
- 软件升级
步骤
源端unplug pdb(连接到CDB$ROOT)
关闭PDB
alter pluggable database PDB1 close immediate;
alter pluggable database PDB1 close immediate instances=all;
将PDB元数据信息保存到xml文件
alter pluggable database PDB1 unplug into '/tmp/PDB1.xml';
XML文件中包含了每个数据文件的位置,以及初始化参数等信息
删除PDB并保留数据文件
drop pluggable database PDB1 keep datafiles;
目标端创建pdb(连接到CDB$ROOT)
检查验证当前CDB环境是否满足条件
set serveroutput on
DECLARE
compatible BOOLEAN := FALSE;
BEGIN
compatible := DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
pdb_descr_file => '/home/oracle/PDB1.xml');
if compatible then
DBMS_OUTPUT.PUT_LINE('Is pluggable database compatible? YES');
else
DBMS_OUTPUT.PUT_LINE('Is pluggable database compatible? NO');
end if;
END;
/
使用xml文件创建PDB
create pluggable database PDB1 using '/tmp/PDB1.xml' NOCOPY;
打开PDB
alter pluggable database PDB1 open;
alter pluggable database PDB1 open instances=all;