千家信息网

12c PDB自启动

发表于:2025-01-19 作者:千家信息网编辑
千家信息网最后更新 2025年01月19日,默认情况下,在CDB 启动的时候,all 的PDB 都是mount状态,也没有默认的机制,在CDB启动时自动启动PDB。这里我们通过触发器的方式实现。CREATE OR REPLACE TRIGGER
千家信息网最后更新 2025年01月19日12c PDB自启动

默认情况下,在CDB 启动的时候,all 的PDB 都是mount状态,也没有默认的机制,在CDB启动时自动启动PDB。

这里我们通过触发器的方式实现。

CREATE OR REPLACE TRIGGER open_pdbsAFTER STARTUP ON DATABASEBEGINEXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE ALL OPEN';END open_pdbs;/

实验过程如下:

SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 1560281088 bytesFixed Size                  2924784 bytesVariable Size             956305168 bytesDatabase Buffers          587202560 bytesRedo Buffers               13848576 bytesDatabase mounted.Database opened.SQL> show pdbs    CON_ID CON_NAME                       OPEN MODE  RESTRICTED---------- ------------------------------ ---------- ----------         2 PDB$SEED                       READ ONLY  NO         3 PDB1                           MOUNTEDSQL> CREATE OR REPLACE TRIGGER open_pdbs  2  AFTER STARTUP ON DATABASE  3  BEGIN  4  EXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE ALL OPEN';  5  END open_pdbs;  6  /Trigger created.SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 1560281088 bytesFixed Size                  2924784 bytesVariable Size             956305168 bytesDatabase Buffers          587202560 bytesRedo Buffers               13848576 bytesDatabase mounted.Database opened.SQL> show con_nameCON_NAME------------------------------CDB$ROOTSQL> show pdbs    CON_ID CON_NAME                       OPEN MODE  RESTRICTED---------- ------------------------------ ---------- ----------         2 PDB$SEED                       READ ONLY  NO         3 PDB1                           READ WRITE NOSQL> 
0