Starting your Oracle Database
One of the most common jobs of the database
administrator is to startup or shutdown the Oracle database. Typically we hope
that database shutdowns will be infrequent for a number of reasons:
* Inconvenience to the user community.
* Anytime you cycle the database, there is a risk that
it will not restart.
* Starting your Oracle database flushes the Oracle memory areas, such as the
database buffer cache.
Performance on a restarted database will generally be
slow until the database memory areas are “warmed” up.
Why would you shutdown your database? Some reasons
include database maintenance:
* Applying a patch or an upgrade.
* Allow for certain types of application maintenance.
* Performing a cold (offline) backup of your database.
(We recommend hot backups that allow you to avoid shutting down your database)
* An existing bug in your Oracle software requires you
to restart the database on a regular basis.
When the time comes to “bounce” the database (using the
shutdown and startup commands), you will use SQL*Plus to issue these commands.
Let’s look at each of these commands in more detail.
The Oracle Startup Command
You start the Oracle database with the startup command.
You must first be logged into an account that has sysdba or sysoper privileges
such as the SYS account (we discussed connecting as SYSDBA earlier in this
book). Here then is an example of a DBA connecting to his database and starting
In this example from a Windows XP server, we set the
ORACLE_SID to the name of the database and we log into SQL*Plus using the “sys
as sysdba” login. This gives us the privileges we need to be able to startup the
database. Finally, after we enter our password, we issue the startup command to
startup the database. Oracle displays its progress as it opens the database, and
then returns us to the SQL*Plus prompt once the startup has been completed.
When Oracle is trying to open your database, it goes
through three distinct stages, and each of these is listed in the startup output
listed previously. These stages are:
* Startup (nomount)
Let’s look at these stages in a bit more detail.
The Startup (nomount) Stage
When you issue the startup command, the first thing the
database will do is enter the nomount stage. During the nomount stage, Oracle
first opens and reads the initialization parameter file (init.ora) to see how
the database is configured. For example, the sizes of all of the memory areas in
Oracle are defined within the parameter file.
After the parameter file is accessed, the memory areas
associated with the database instance are allocated. Also, during the nomount
stage, the Oracle background processes are started. Together, we call these
processes and the associated allocated memory the Oracle instance. Once the
instance has started successfully, the database is considered to be in the
nomount stage. If you issue the startup command, then Oracle will automatically
move onto the next stage of the startup, the mount stage.
Starting the Oracle Instance (Nomount Stage)
There are some types of Oracle recovery operations that
require the database to be in nomount stage. When this is the case, you need to
issue a special startup command: startup nomount, as seen in this example:
SQL> startup nomount
The Mount Stage
When the startup command enters the mount stage, it
opens and reads the control file. The control file is a binary file that tracks
important database information, such as the location of the database datafiles.
In the mount stage, Oracle determines the location of
the datafiles, but does not yet open them. Once the datafile locations have been
identified, the database is ready to be opened.
Mounting the Database
Some forms of recovery require that the database be
opened in mount stage. To put the database in mount stage, use the startup mount
command as seen here:
SQL> startup mount
If you have already started the database instance with
the startup nomount command, you might change it from the nomount to mount
startup stage using the alter database command:
SQL> alter database mount;
The Open Oracle startup Stage
The last startup step for an Oracle database is the open
stage. When Oracle opens the database, it accesses all of the datafiles
associated with the database. Once it has accessed the database datafiles,
Oracle makes sure that all of the database datafiles are consistent.
Opening the Oracle Database
To open the database, you can just use the startup
command as seen in this example
If the database is mounted, you can open it with the
alter database open command as seen in this example:
SQL> alter database open;
Opening the Database in Restricted Mode
You can also start the database in restricted mode.
Restricted mode will only allow users with special privileges (we will discuss
user privileges in a later chapter) to access the database (typically DBA’s),
even though the database is technically open. We use the startup restrict
command to open the database in restricted mode as seen in this example.
SQL> startup restrict
You can take the database in and out of restricted mode
with the alter database command as seen in this example:
-- Put the database in restricted session mode.
SQL> alter system enable restricted session;
-- Take the database out of restricted session mode.
SQL> alter system disable restricted session;
Note: Any users connected to the Oracle instance when
going into restricted mode will remain connected; they must be manually
disconnected from the database by exiting gracefully or by the DBA with the
“alter system kill session” command.
Problems during Oracle Startup
The typical DBA life is like that of an airline pilot,
“Long moments of boredom followed by small moments of sheer terror”, and one
place for sheer terror is an error during a database startup.
The most typical reason for a database not starting up
is a prior database crash, a data corruption, disk failure or some other
catastrophic event from which the database cannot recover. In these cases, you
have to go into database recovery mode to start your instance. There is a
chapter on recovery later in this book and we will discuss what to do when
Oracle will not startup.
This is an excerpt from the bestselling "Easy
Oracle Jumpstart" by Robert Freeman and Steve Karam (Oracle ACE and Oracle
Certified Master). It’s only $19.95 when you buy it directly from the
If you like Oracle tuning, you may enjoy the new book "Oracle
Tuning: The Definitive Reference", over 900 pages of BC's favorite tuning
tips & scripts.
You can buy it direct from the publisher for 30%-off and get instant access to
the code depot of Oracle tuning scripts.