--DB启动后,默认是不启动PDB,可通过触发器来实现
CREATE TRIGGERopen_all_pdbs
AFTER STARTUP
ON DATABASE
BEGIN
EXECUTE IMMEDIATE 'alter pluggable databaseall open';
ENDopen_all_pdbs;
/
--CDB中PDB创建的几种方法
方法一:
create pluggable database zaki4 from zaki1 file_name_convert= ('/oracle/db/oradata/orcl/zaki1','/oracle/db/oradata/orcl/zaki4');
create pluggabled atabase zaki8 from zaki2 file_name_convert= ('/oracle/db/oradata/orcl/zaki2','/oracle/db/oradata/orcl/zaki8') snapshot copy;--需要操作系统支持snapshot
方法二:
alter pluggable database zaki5 close;
alter pluggable database zaki5 unplug into '/oracle/db/oradata/orcl/zaki1/zaki5.xml';
DECLARE
l_result BOOLEAN;
BEGIN
l_result :=DBMS_PDB.check_plug_compatibility(pdb_descr_file =>'/oracle/db/oradata/orcl/zaki1/zaki5.xml',pdb_name => 'zaki5');
IF l_result THEN
DBMS_OUTPUT.PUT_LINE('compatible');
ELSE
DBMS_OUTPUT.PUT_LINE('incompatible');
END IF;
END;
/
create pluggabledatabase zaki5 using '/oracle/db/oradata/orcl/zaki1/zaki5.xml' nocopy tempfilereuse; (source_file_name_convert)
方法三:
CREATE PLUGGABLEDATABASE zaki5 admin user zwh identified by zwh
PATH_PREFIX='/oracle/db/oradata/orcl/zaki5/'
FILE_NAME_CONVERT= ('/oracle/db/oradata/orcl/pdbseed/','/oracle/db/oradata/orcl/zaki5/');
或者
CREATE PLUGGABLEDATABASE zaki6 admin user zwh identified by zwh
STORAGE (MAXSIZE2G MAX_SHARED_TEMP_SIZE 100M)
DEFAULTTABLESPACE lex datafile'/oracle/db/oradata/orcl/zaki6/zwh.dbf' size 100M
PATH_PREFIX='/oracle/db/oradata/orcl/zaki6/'
FILE_NAME_CONVERT= ('/oracle/db/oradata/orcl/pdbseed/','/oracle/db/oradata/orcl/zaki6/');
--查看新建的zaki8状态并以只读方式打开
selectpdb_id,pdb_name,dbid,STATUS,CREATION_SCN from dba_pdbs;
alter pluggabledatabase zaki8 close;
alter pluggabledatabase zaki8 open read only;