Description of startup and shutdown for Oracle 12c CDB and PDB databases

Source: Internet
Author: User
Tags sqlplus


In Oracle 12c, the CDB and PDB, their startup and shutdown operations are organized as follows.

1 Container Database (CDB)

For CDB, startup and shutdown are the same as in previous traditional ways, with the following syntax:

Startup[nomount | MOUNT | RESTRICT | UPGRADE | Force | READ only]

Shutdown[immediate | ABORT]

Note that after the 12c database is created, by default the sqlplus/as sysdba login is connected to the CDB.

[Email protected]~]$ sqlplus/as SYSDBA

Sql*plus:release 12.1.0.1.0 Production on Thu APR 24 17:50:34 2014

Copyright (c) 1982, Oracle. All rightsreserved.

Connectedto:

Oracledatabase 12c Enterprise Edition Release 12.1.0.1.0-64bit Production

Withthe partitioning, OLAP, Advanced Analytics and Real application testing options

Sql>show Con_name

Con_name

------------------------------

Cdb$root

Sql>

Sql>select con_id, dbid, GUID, name, open_mode from V$pdbs;

con_id DBID GUID NAME Open_mode

---------- ------------------------------------------ ------------------------------ ----------

2 4088301206 f7c1e3c96bbf0585e0430a01a8c05459pdb$seed READ only

3 426143573 f7c209eb1dfc0854e0430a01a8c0b787 pdbcndba READ WRITE

We are now connected to the CDB, which is root container.

We closed CDB:

Sql>shutdown Immediate

Databaseclosed.

Databasedismounted.

Oracleinstance shut down.

The PDB was not closed before we closed the CDB, so this operation would also close the PDB off.

Sql>startup

Oracleinstance started.

Totalsystem Global Area 1269366784 bytes

Fixedsize 2287912 bytes

Variablesize 788530904 bytes

Databasebuffers 469762048 bytes

Redobuffers 8785920 bytes

Databasemounted.

databaseopened.

Sql> Select con_id, dbid, GUID, name, Open_modefrom V$pdbs;

con_id DBID GUID NAME Open_mode

---------- ------------------------------------------ ------------------------------ ----------

2 4088301206f7c1e3c96bbf0585e0430a01a8c05459 pdb$seed READ only

3 426143573 f7c209eb1dfc0854e0430a01a8c0b787 pdbcndba mounted

Note here that the PDB, when CDB is started, the PDB is automatically booted into the Mount state instead of open. So we also need to manually open it, of course, you can also configure the trigger in the CDB to automatically open.

2 pluggable Database (PDB)

The operation of the PDB can be done either through sql*plus or by the Alter pluggable DATABASE command.

2.1 Using the Sql*plus command

Because the default connection is CDB, you must specify the PDB before you can start and close the PDB via Sqlplus.

The exact syntax is the same as for a normal instance:

Startupforce;

Startupopen READ WRITE [RESTRICT];

Startupopen READ only [RESTRICT];

Startupupgrade;

Shutdown[immediate];

Sql>show Con_name

Con_name

------------------------------

Cdb$root

sql>selectcon_id, dbid, GUID, name, open_mode from V$pdbs;

con_id DBID GUID NAME Open_mode

-------------------- -------------------------------- --------------- ----------

2 4088301206f7c1e3c96bbf0585e0430a01a8c05459 pdb$seed READ only

3 426143573 f7c209eb1dfc0854e0430a01a8c0b787 pdbcndba mounted

Note that this is mount, which means that the PDB is closed.

-- Specify the PDB database:

Sql>alter session set container=pdbcndba;

Sessionaltered.

Sql>startup

Pluggabledatabase opened.

Sql>select con_id, dbid, GUID, name, open_mode from V$pdbs;

con_id DBID GUID NAME Open_mode

-------------------- -------------------------------- --------------- ----------

3 426143573 f7c209eb1dfc0854e0430a01a8c0b787 pdbcndba READ WRITE

Sql>

Started successfully. When we switch to the PDB, we don't see the information for the seed PDB.

2.2 Using the Alter PLUGGABLE database command

If you can use the following syntax in the PDB :

Alterpluggable DATABASE OPEN READ WRITE [RESTRICTED] [force];

Alterpluggable DATABASE OPEN READ only [RESTRICTED] [force];

alterpluggable DATABASE OPEN UPGRADE [RESTRICTED];

Alterpluggable DATABASE CLOSE [IMMEDIATE];

if you are in CDB , you can use the following syntax:

Alterpluggable DATABASE <pdd-name-clause> OPEN READ WRITE [Restricted][force];

Alterpluggable DATABASE <pdd-name-clause> OPEN READ only [RESTRICTED] [force];

Alterpluggable DATABASE <pdd-name-clause> OPEN UPGRADE [RESTRICTED];

alterpluggable DATABASE <pdd-name-clause> CLOSE [IMMEDIATE];

<pdd-name-clause> represents multiple pdb, separated by commas if there are multiple. You can also use the all or all except keywords instead.

All: Represents all the PDBs.

Allexcept indicates the PDBs to be excluded.

Such as:

Alterpluggable DATABASE pdb1, pdb2 OPEN READ only force;

Alterpluggable DATABASE pdb1, pdb2 CLOSE IMMEDIATE;

Alterpluggable DATABASE all OPEN;

Alterpluggable DATABASE all CLOSE IMMEDIATE;

Alterpluggable DATABASE all EXCEPT pdb1 OPEN;

Alterpluggable DATABASE all EXCEPT pdb1 CLOSE IMMEDIATE;

Example:

Sql>alter session Set Container=cdb$root;

Sessionaltered.

Sql>select con_id, dbid, GUID, name, open_mode from V$pdbs;

con_id DBID GUID NAME Open_mode

-------------------- -------------------------------- --------------- ----------

2 4088301206f7c1e3c96bbf0585e0430a01a8c05459 pdb$seed READ only

3 426143573 f7c209eb1dfc0854e0430a01a8c0b787 pdbcndba READ WRITE

Sql>alter pluggable DATABASE all CLOSE;

Pluggabledatabase altered.

Sql>select con_id, dbid, GUID, name, open_mode from V$pdbs;

con_id DBID GUID NAME Open_mode

-------------------- -------------------------------- --------------- ----------

2 4088301206f7c1e3c96bbf0585e0430a01a8c05459 pdb$seed READ only

3 426143573 F7C209EB1DFC0854E0430A01A8C0B787PDBCNDBA Mounted

Sql>alter session Set CONTAINER=PDBCNDBA;

Sessionaltered.

Sql>alter pluggable DATABASE OPEN;

Pluggabledatabase altered.

Sql> Select con_id, dbid, GUID, name, Open_modefrom V$pdbs;

con_id DBID GUID NAME Open_mode

-------------------- -------------------------------- --------------- ----------

3 426143573 f7c209eb1dfc0854e0430a01a8c0b787pdbcndba READ WRITE

3 Setting the pluggable Database (PDB) Auto Startup

By default, when CDB starts, the PDB for all is the Mount state, and there is no default mechanism to start the PDB automatically when CDB starts.

However, the automatic open of the PDB can be implemented by a trigger:

Createor REPLACE TRIGGER Open_pdbs

After STARTUP on DATABASE

BEGIN

EXECUTE IMMEDIATE ' alterpluggable DATABASE all OPEN ';

END Open_pdbs;

/

Example:

Sql>show Con_name

Con_name

------------------------------

Pdbcndba

Sql>alter session Set Container=cdb$root;

Sessionaltered.

Sql>create OR REPLACE TRIGGER Open_pdbs

2 after STARTUP on DATABASE

3 BEGIN

4 EXECUTE IMMEDIATE ' ALTER pluggable DATABASE all OPEN ';

5 Endopen_pdbs;

6/

Triggercreated.

--------------------------------------------------------------------------------------------

Copyright, the article allows reprint, but must be linked to the source address, otherwise investigate legal responsibility!

Aboutdave:

--------------------------------------------------------------------------------------------

qq:251097186

Email: [email protected]

Blog:http://blog.csdn.net/tianlesoftware

Weibo:http://weibo.com/tianlesoftware

Twitter:http://twitter.com/tianlesoftware

Facebook:http://www.facebook.com/tianlesoftware

Linkedin:http://cn.linkedin.com/in/tianlesoftware

Dave's QQ Group:

--------------------------------------------------------------------------------------------

Note: Add group must indicate tablespace and data file relationship | Do not repeat the addition group

cndba_1:104207940 (Full) cndba_2:62697716 (full) cndba_3:283816689

cndba_4:391125754 cndba_5:62697850 cndba_6:62697977 cndba_7:142216823 (full)

Description of startup and shutdown for Oracle 12c CDB and PDB databases

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.