Oracle Startup and Shutdown
Version 21c

General Information
Library Note Morgan's Library Page Header
ACE Director Alum Daniel Morgan, founder of Morgan's Library, is scheduling complimentary technical Workshops on Database Security for the first 30 Oracle Database customers located anywhere in North America, EMEA, LATAM, or APAC that send an email to asra_us@oracle.com. Request a Workshop for your organization today.
Note Starting and stopping the 12c, or above, multi-tenant database is different from starting and stopping a legacy architecture database. What is true in CDB$ROOT is not true in a PDB.

You will note a substantial change in this page from all library pages on this subject since the library was started. Now the container name is critical to understanding what to expect and the word database is dropped as it is a term rendered essentially meaningless by the new architecture. The startup demos assume that you have just rebooted the server and that no shell scripts have been written that automatically perform a startup function.

Startup commands executed in CDB$ROOT only affect CDB$ROOT whereas shutdown commands affect all PDBs. Startup and shutdown commands executed within a PDB only affect that single PDB. Here's why:

STARTUP consists of three separate operations:

  1. NOMOUNT: Read the initialization file which provides information defining the instance (memory structures) and the location of the control files.
  2. MOUNT: Read the control file which proves information on the location of tablespace data and temp files.
  3. OPEN: Open the datafiles for access
    or
  4. OPEN RESTRICTED: Open the datafiles for access but limit connections to only those with RESTRICTED SESSION privileges
When you perform a STARTUP it reads the spfile, there is only one for the entire CDB and one of the control files, which are all identical and for which there is only one set for the entire CDB. It then opens for access only those tablespaces and datafiles associated with CDB$ROOT and PDB$SEED. This makes sense as you wouldn't want a situation where you had 20 PDBs, only 5 of which you actually were using, and they were all opened by default. To open PDBs you must use the ALTER PLUGGABLE DATABASE syntax shown below.

SHUTDOWN also contains differences from what is "expected" behaviour. If you are in CDB$ROOT and you issue a shutdown you shutdown everything: CDB$ROOT, PDB$SEED, and every PDB you have created: Makes sense because you only have on instance with memory structures. But if you are logged into a PDB the rules are very different. A PDB is just a collection of files and has no memory structures so no matter what you do: SHUTDOWN, SHUTDOWN IMMEDIATE, SHUTDOWN ABORT what you actually do is change the status of that one PDB, and only that one PDB, to MOUNT state.
System Privileges
SYSDBA SYSOPER  
 
CDB Management
Start CDB
Startup STARTUP [FORCE][RESTRICT][NOMOUNT][MIGRATE][QUIET]
[PFILE=<file_name>]
[MOUNT [EXCLUSIVE] <database_name>x |
OPEN <READ {ONLY | WRITE [RECOVER]} | RECOVER>
<database_name>]
SQL> conn / as sysdba

SQL> STARTUP
Startup Force SQL> STARTUP FORCE
Startup Mount SQL> STARTUP MOUNT
Startup Nomount SQL> STARTUP NOMOUNT
Startup Mount Exclusive Deprecated .. now use STARTUP MOUNT
Startup Open SQL> STARTUP OPEN
Startup Migrate SQL> STARTUP MIGRATE
Startup Restricted SQL> STARTUP RESTRICT
Startup <upgrade> STARTUP [PFILE=<file_name>]{UPGRADE | DOWNGRADE} [QUIET]
SQL> STARTUP UPGRADE
Alter CDB
Alter Database Mount SQL> ALTER DATABASE NOMOUNT
SQL> ALTER DATABASE MOUNT
Alter Database Open SQL> ALTER DATABASE NOMOUNT
SQL> ALTER DATABASE MOUNT
SQL> ALTER DATABASE OPEN
Shutdown CDB
Shutdown SHUTDOWN <ABORT | IMMEDIATE | TRANSACTIONAL[LOCAL]>
SQL> SHUTDOWN
Shutdown Normal (deprecated) SQL> SHUTDOWN NORMAL
Shutdown Transactional SQL> SHUTDOWN TRANSACTIONAL
Shutdown Immediate (the default) SQL> SHUTDOWN IMMEDIATE
Shutdown Abort SQL> SHUTDOWN ABORT
 
PDB Management
Start PDB
Startup One PDB ALTER PLUGGABLE DATABASE <pdb_name> OPEN;
conn / as sysdba

SQL> ALTER PLUGGABLE DATABASE pdbdev OPEN;
Startup All PDBs ALTER PLUGGABLE DATABASE ALL OPEN;
conn / as sysdba

SQL> ALTER PLUGGABLE DATABASE ALL OPEN;
Startup from within a PDB STARTUP [READ WRITE]
SQL> STARTUP;
Read Only Startup from within a PDB STARTUP READ ONLY
SQL> STARTUP READ ONLY;
Alter PDB
Alter Database Close SQL> show con_name
PDBDEV

SQL> alter database close;
alter database close
*
ERROR at line 1:

ORA-65040: operation not allowed from within a pluggable database
Shutdown PDB
Shutdown SHUTDOWN <ABORT | IMMEDIATE | NORMAL>
SQL> SHUTDOWN

SELECT name, open_mode
FROM v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDBDEV                         MOUNTED

SQL> STARTUP

SHUTDOWN ABORT;
Pluggable Database closed.

SELECT name, open_mode
FROM v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDBDEV                         MOUNTED
Invalid Shutdown SQL> SHUTDOWN TRANSACTIONAL;
SP2-0717: illegal SHUTDOWN option
 
Oracle Supplied Startup & Shutdown Scripts
Startup dbstart
Shutdown dbshut
 
System Hangs On Shutdown
Solution SQL> alter system checkpoint;
SQL> shutdown abort;
SQL> startup restrict;
SQL> shutdown immediate;
 
Oracle Services On Windows
CDB Startup net start OracleService<SID>
c:\windows\system32 net start oracleserviceorabase
CDB Shutdown net stop OracleService<SID>
c:\windows\system32 net stop oracleserviceorabase
Help net<error_msg_number>
c:\windows\system32 net help helpmsg

The syntax of this command is:

NET HELPMSG message#

NET HELPMSG displays information about Windows network messages (such as error, warning, and alert messages). When you type NET HELPMSG and the 4-digit number of the Windows error (for example, NET2182), Windows tells you about the message and suggests action you can take to solve a problem.

message# Is the 4-digit number of the Windows message you need help with. You don't need to type NET as part of the message number.
 
Oracle Services On Windows With Oradim
Start Oracle Service oradim -STARTUP
[-SID <side_name> | -ASMSID <sid> [-SYSPWD <password>]
[STARTTYPE <service_name | instance_name | service_name,instance_name]
[-PFILE <file_name> | -SPFILE]
$ORACLE_HOME\bin\oradim -STARTUP -SID orabase -STARTTYPE tstc -SPFILE
Stop Oracle Service oradim -SHUTDOWN
[-SID <side_name> | -ASMSID <sid> [-SYSPWD <password>]
[-SHUTTYPE <service_name | instance_name | service_name,instance_name]
[-SHUTMODE <normal | immediate | abort>
$ORACLE_HOME\bin\oradim -SHUTDOWN -SID orabase -SHUTMODE abort
 
Stopping Processes
When stop doesn't stop alter database close may fail for many reasons. Among them job queue processes, dbms_job, and advanced queuing.

SQL> ALTER DATABASE CLOSE;
alter database close
*
ERROR at line 1:
ORA-01093: ALTER DATABASE CLOSE only permitted with no sessions connected


col username format a20
col schemaname format a20
col osuser format a20
SELECT username, schemaname, osuser, status
FROM gv$session;

ALTER SYSTEM SET job_queue_processes = 0 SCOPE=MEMORY;

ALTER SYSTEM SET aq_tm_processes=0 SCOPE=MEMORY;

ALTER DATABASE CLOSE;
Force log files to be archived in preparation for media recovery STARTUP MOUNT;
ALTER DATABASE orabase ARCHIVELOG;
ALTER SYSTEM archive log START;
ALTER DATABASE OPEN;
When testing startup scripts be sure to mimic the environment under which the script will actually run For example:

sh -x /etc/init.d/oracle start

Related Topics
Database
ORADIM
System
What's New In 21c
What's New In 23c

Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2023 Daniel A. Morgan All Rights Reserved
  DBSecWorx