3 Database Startup Shutdown And Initialization

Database Administration · Unit 3

Database Startup, Shutdown and Initialization

Exam-focused notes for Database Startup, Shutdown and Initialization (Database Administration, BIT352): what the TU syllabus asks and how it has actually been tested, with 2 solved past questions from this unit.

Database Startup, Shutdown and Initialization in short

This chapter shows how to start and stop an Oracle database, and how its settings are stored. A DBA does these tasks often during maintenance, backup and recovery.

Database Startup, Shutdown and Initialization: notes

Database startup modes and commands

Oracle starts in stages. Each stage reads more of the system.

StageCommandWhat happens
NOMOUNTSTARTUP NOMOUNTInstance starts: parameter file is read, SGA and background processes are created
MOUNTSTARTUP MOUNTControl file is opened; database is mounted but datafiles are closed
OPENSTARTUP or STARTUP OPENDatafiles and redo logs are opened; users can connect

Other startup options:

  • STARTUP RESTRICT: only users with the RESTRICTED SESSION privilege can connect.
  • STARTUP FORCE: does a SHUTDOWN ABORT first and then a normal startup.
CONNECT / AS SYSDBA
STARTUP NOMOUNT;
ALTER DATABASE MOUNT;
ALTER DATABASE OPEN;

NOMOUNT is used to create a database or to rebuild a control file. MOUNT is used to rename files, to turn archive logging on, and for full recovery.

Database shutdown modes and commands

Shutdown has four modes.

ModeNew connectionsWaits forRecovery at next start
NORMALNot allowedAll users to disconnectNo
TRANSACTIONALNot allowedActive transactions to finishNo
IMMEDIATENot allowedNothing; open transactions are rolled backNo
ABORTNot allowedNothing; instance stops at onceYes, instance recovery
SHUTDOWN IMMEDIATE;

SHUTDOWN IMMEDIATE is the usual choice. SHUTDOWN ABORT is a last step when other modes hang. It leaves the files inconsistent, so SMON must do instance recovery at the next startup. Take cold backups only after NORMAL, TRANSACTIONAL or IMMEDIATE.

What this unit covers

  • Database startup modes and commands
  • Database shutdown modes and commands
  • Initialization parameter files
  • Spfile versus Pfile differentiation
  • Oracle defined roles and their usage

Spfile versus Pfile differentiation

2081.1 · 10 marks

What is initialization parameter file? Differentiate between Spfile and Pfile. Explain some oracle defined roles with suitable example.[10]

Show solved answer

Initialization Parameter File, Spfile vs Pfile, and Oracle Defined Roles

Note: The reference notes did not contain material on this topic. The following answer is based on standard Oracle Database concepts as taught in BSc CSIT Database Administration courses.


1. Initialization Parameter File

An Initialization Parameter File (also called an init file) is a configuration file used by Oracle Database to read startup parameters when the database instance is started.

  • It contains a list of key = value pairs that define how the Oracle instance behaves.
  • Parameters include memory sizes, file locations, database name, number of processes, etc.
  • Oracle reads this file at instance startup to configure the System Global Area (SGA), background processes, and other settings.

Example entries:

db_name = ORCL
memory_target = 512M
processes = 150
control_files = ('/u01/oradata/control01.ctl')

2. Difference Between SPFILE and PFILE

FeatureSPFILE (Server Parameter File)PFILE (Parameter File / init.ora)
Full FormServer Parameter FileParameter File (also called init.ora)
FormatBinary filePlain text file
LocationStored on the server side (managed by Oracle)Can be stored anywhere; typically in $ORACLE_HOME/dbs/
EditingCannot be edited manually; modified using ALTER SYSTEM commandCan be edited manually using any text editor
Persistence of ChangesChanges made with ALTER SYSTEM are automatically persistent across restartsChanges must be manually saved; not automatically persistent
Default Namespfile<SID>.orainit<SID>.ora
Introduced InOracle 9i onwardsAvailable since early Oracle versions
RecommendedYes, recommended for production useUsed for testing or when SPFILE is unavailable
Dynamic ChangesSupports dynamic parameter changes with SCOPE=BOTH/MEMORY/SPFILEDoes not support dynamic changes
BackupCan be backed up using RMANManually backed up

Creating SPFILE from PFILE:

CREATE SPFILE FROM PFILE = '/u01/oracle/initORCL.ora';

Creating PFILE from SPFILE:

CREATE PFILE = '/u01/oracle/initORCL.ora' FROM SPFILE;

Modifying SPFILE parameter:

ALTER SYSTEM SET memory_target = 1G SCOPE = SPFILE;

3. Oracle Defined Roles

A Role in Oracle is a named group of related privileges that can be granted to users or other roles. Oracle provides several predefined (system-defined) roles to simplify privilege management.

Common Oracle Defined Roles:


a) CONNECT Role

  • Grants the privilege to connect to the database.
  • Historically included CREATE TABLE, CREATE VIEW, etc., but in Oracle 10g onwards it only includes the CREATE SESSION privilege.
GRANT CONNECT TO john;
-- Now john can log in to the database

b) RESOURCE Role

  • Grants privileges to create database objects such as tables, sequences, procedures, triggers, etc.
  • Suitable for application developers.

Privileges included:

  • CREATE TABLE
  • CREATE SEQUENCE
  • CREATE PROCEDURE
  • CREATE TRIGGER
  • CREATE TYPE
GRANT RESOURCE TO john;
-- Now john can create tables, sequences, procedures, etc.

c) DBA Role

  • The most powerful predefined role in Oracle.
  • Grants all system privileges WITH ADMIN OPTION, meaning the user can also grant those privileges to others.
  • Should be granted only to database administrators.
GRANT DBA TO admin_user;
-- admin_user now has full administrative privileges

d) SELECT_CATALOG_ROLE

  • Grants SELECT privilege on all data dictionary views (DBA_* views).
  • Useful for users who need to query the data dictionary without having full DBA access.
GRANT SELECT_CATALOG_ROLE TO analyst;
-- analyst can now query DBA_TABLES, DBA_USERS, etc.

e) EXP_FULL_DATABASE and IMP_FULL_DATABASE Roles

  • EXP_FULL_DATABASE: Grants privileges needed to perform a full database export using Oracle Data Pump or exp utility.
  • IMP_FULL_DATABASE: Grants privileges needed to perform a full database import.
GRANT EXP_FULL_DATABASE TO backup_user;
GRANT IMP_FULL_DATABASE TO restore_user;

f) SCHEDULER_ADMIN Role

  • Grants privileges to manage Oracle Scheduler jobs, programs, and chains.
GRANT SCHEDULER_ADMIN TO job_manager;

Summary Table of Oracle Defined Roles

RolePurpose
CONNECTAllows user to connect/login to database
RESOURCEAllows creation of database objects
DBAFull administrative privileges
SELECT_CATALOG_ROLERead access to data dictionary
EXP_FULL_DATABASEFull database export
IMP_FULL_DATABASEFull database import
SCHEDULER_ADMINManage Oracle Scheduler

Granting and Revoking Roles:

-- Grant a role
GRANT CONNECT, RESOURCE TO john;

-- Revoke a role
REVOKE RESOURCE FROM john;

-- Check roles granted to a user
SELECT * FROM DBA_ROLE_PRIVS WHERE GRANTEE = 'JOHN';

Key Benefit of Roles: Instead of granting individual privileges to each user, a DBA can grant a role (bundle of privileges) to multiple users, making privilege management easier and more efficient.

Open this answer on its own page →

Database startup modes and commands

0 · 5 marks

Explain oracle database startup and shutdown modes with respective commands. [5]

Note: The reference notes did not contain this topic. The following answer is based on standard Oracle Database administration concepts, which are part of the TU BSc CSIT Database Administration curriculum. --- Oracle database startup is a three-stage process. Each stage corresponds to a startup ...

Open this answer on its own page →