• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Use Startup, Shutdown, and Alter Database commands in Oracle 12c

by admin

Before 12c there are only a few commands available for startup and shutdown but if we follow that we end up starting and stopping only cdb. The commands in 12c to start and shutdown the CDB and PDB are a little different than the previous version. Below list of commands were used in earlier versions prior to 12c:

shutdown normal
shutdown immediate
shutdown abort
startup
startup nomount
startup mount

If we use one of these traditional shutdown methods at the container database (CDB) layer, we will bring down the CDB and the associated PDBs under it. This is something to be aware of when looking to reboot container databases.

Lets take a look at bringing down a CDB.

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
ora12c

SQL> show con_name;

CON_NAME
------------------------------
CDB$ROOT
SQL> shutdown immediate;

Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> alter session set container=PDB1;

alter session set container=PDB1
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0

Now, that we established that SHUTDOWN IMMEDIATE at the CDB level will close the CDB and all other PDBs. How can we shutdown just a single PDB if needed?

There are two different ways to shutdown a PDB.

From the CDB layer

We use this method for maintenance purpose without affecting other pdb. We can shutdown a PDB from the CDB level using the ALTER PLUGGABLE DATABASE command.

alter pluggable database open read write
alter pluggable database open read only
alter pluggable database open upgrade
alter pluggable database close

For example, first find out current state of pdb’s:

SQL> select con_id, name, open_mode from v$pdbs;

CON_ID     NAME                           OPEN_MODE
---------- ------------------------------ ----------
 2         PDB$SEED                       READ ONLY
 3         PDB1                           MOUNTED
 4         PDBTEST                        MOUNTED
 5         PDB2                           MOUNTED

How to open these pdb’s:

SQL> alter pluggable database PDB1 open;

Pluggable database altered.
SQL> select con_id, name, open_mode from v$pdbs;

CON_ID     NAME                           OPEN_MODE
---------- ------------------------------ ----------
 2         PDB$SEED                       READ ONLY
 3         PDB1                           READ WRITE
 4         PDBTEST                        MOUNTED
 5         PDB2                           MOUNTED

Open command in pdb is alter pluggable database and not the legacy startup command.

From the PDB layer

We can use the normal SHUTDOWN commands as we would with a traditional database. In order to do this, we have to be in that PDB container first.

Here is an example of closing PDB1 with the SHUTDOWN command.

SQL> alter session set container=PDB1;

Session altered.

SQL> select con_id, name, open_mode from v$pdbs;

CON_ID     NAME                           OPEN_MODE
---------- ------------------------------ ----------
 3         PDB1                           READ WRITE
SQL> shutdown immediate;

Pluggable Database closed.
SQL> select con_id, name, open_mode from v$pdbs;

CON_ID     NAME                           OPEN_MODE
---------- ------------------------------ ----------
 3         PDB1                           MOUNTED

Filed Under: oracle, oracle 12c, Oracle 18c, Oracle 19c

Some more articles you might also be interested in …

  1. Error: ORA-16810: multiple errors or warnings detected for the database
  2. Oracle Database interview questions – Privileges And Roles
  3. How to move spfile from ASM to filesystem
  4. How to Create Undo Tablespace for a Newly Added RAC Instance (ORA-30012)
  5. How To Change SYS user password for oracle database instance
  6. DNS and DHCP Setup Example for Oracle Grid Infrastructure GNS
  7. How to Restore a Dropped Pluggable Database (PDB) in Multitenant Environment
  8. Understanding the Global Resource Management Concepts in Oracle RAC
  9. Background Processes Specific to Oracle RAC
  10. ORA-65208: Lockdown profile P1 does not exist

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright