★ 知识点
※ DEFAULT_SHARING参数的取值
- METADATA: 元数据链接共享数据库对象的元数据,但其数据对于每个容器是唯一的。这些数据库对象被称为元数据链接的应用程序公共对象。此设置为默认设置。
- DATA: 数据链接共享数据库对象,其数据对于应用程序容器中的所有容器都是相同的。它的数据只存储在应用程序根目录中。这些数据库对象称为数据链接应用程序公共对象.
- EXTENDED DATA: 扩展数据链接共享数据库对象,其在应用程序根目录中的数据对于应用程序容器中的所有容器都是相同的。但是,应用程序容器中的每个应用程序PDB都可以存储该应用程序PDB独有的数据。对于这种类型的数据库对象,数据存储在应用程序根目录中,也可选地存储在每个应用程序PDB中。这些数据库对象被称为扩展数据链接应用程序公共对象.
- NONE: 不共享数据库对象
✔ 安装
alter session set container=APP1_ROOT;
alter system set default_sharing='METADATA' scope=both;
alter pluggable database application app1_root begin install '1';
drop user zzt_pub cascade;
create user zzt_pub identified by zzt;
grant dba,unlimited tablespace to zzt_pub;
create table zzt_pub.t(id int,name varchar2(9));
alter pluggable database application app1_root end install '1';
insert into zzt_pub.t values(1,'a');
commit;
--将应用容器中的Application Release同步到应用PDB中
alter session set container=APP1_pdb1;
alter pluggable database application all sync;
select * from zzt_pub.t;
alter session set container=APP1_pdb2;
alter pluggable database application all sync;
select * from zzt_pub.t;
alter session set container=APP1_ROOT;
select * from zzt_pub.t;
✔ 升级
--版本 1 to 2
alter session set container=app1_root;
alter system set default_sharing='METADATA' scope=both;
alter pluggable database application app1_root begin upgrade '1' to '2';
alter table zzt_pub.t add(ver int);
update zzt_pub.t set ver=1;
commit;
alter pluggable database application app1_root end upgrade to '2';
--版本 2 to 3
alter session set container=app1_root;
alter system set default_sharing='METADATA' scope=both;
alter pluggable database application app1_root begin upgrade '2' to '3';
alter table zzt_pub.t add(country varchar2(9));
update zzt_pub.t set country='china';
commit;
alter pluggable database application app1_root end upgrade to '3';
--将应用容器中的版本同步到应用pdb中
alter session set container=app1_root;
select * from zzt_pub.t;
alter session set container=app1_pdb1;
alter pluggable database application app1_root sync to '2';
select * from zzt_pub.t;
alter session set container=app1_pdb2;
alter pluggable database application app1_root sync to '3';
select * from zzt_pub.t;
✔ 打补丁
--给2打补丁
alter session set container=APP1_ROOT;
alter system set default_sharing='METADATA' scope=both;
alter pluggable database application app1_root begin patch 222 minimum version '2';
update zzt_pub.t set ver=2;
commit;
alter pluggable database application app1_root end patch 222;
--给3打补丁
alter session set container=APP1_ROOT;
alter system set default_sharing='METADATA' scope=both;
alter pluggable database application app1_root begin patch 333 minimum version '3';
update zzt_pub.t set ver=3;
commit;
alter pluggable database application app1_root end patch 333;
--同步
alter session set container=app1_root;
select * from zzt_pub.t;
alter session set container=app1_pdb1;
alter pluggable database application app1_root sync to patch 222;
select * from zzt_pub.t;
alter session set container=app1_pdb2;
alter pluggable database application app1_root sync to patch 333;
select * from zzt_pub.t;
✔ 卸载
alter session set container=app1_root;
alter system set default_sharing='METADATA' scope=both;
alter pluggable database application app1_root begin uninstall;
drop user zzt_pub cascade;
alter pluggable database application app1_root end uninstall;
--同步
alter session set container=app1_pdb1;
alter pluggable database application app1_root sync;
alter session set container=app1_pdb2;
alter pluggable database application app1_root sync;
--删除application root
alter session set container=cdb$root;
alter pluggable database APP1_ROOT close;
drop pluggable database APP1_PDB1 including datafiles;
drop pluggable database APP1_PDB2 including datafiles;
drop pluggable database APP1_ROOT including datafiles;
--查验application root clone是否被删除
alter session set container=cdb$root;
show pdbs;