3.5 Shutting Down the Database
Logically enough, the process of shutting down a database or making
it inaccessible involves steps that reverse those discussed in the
previous section:Closing the database.
Oracle flushes any modified database
blocks that haven't yet been written to the disk
from the SGA cache to the datafiles. Oracle also writes out any
relevant redo information remaining in the redo log buffer. Oracle
then checkpoints the datafiles, marking the datafile headers as
"current" as of the time the
database was closed, and closes the datafiles and redo log files. At
this point, users can no longer access the database.Dismounting the database. The Oracle instance dismounts the database.
Oracle updates the relevant entries in the control files to record a
clean shutdown and then closes them. At this point, the entire
database is closed; only the instance remains.Shutting down the instance.
The Oracle software stops the background
processes of the instance and frees, or deallocates, the shared
memory used for the SGA.
In some cases (e.g., if there is a machine failure or the DBA aborts
the instance), the database may not be closed cleanly. If this
happens, Oracle doesn't have a chance to write the
modified database blocks from the SGA to the datafiles. When Oracle
is started again, the instance will detect that a crash occurred and
will use the redo logs to automatically perform what is called
crash recovery.
Crash recovery guarantees that the changes for all committed
transactions are done and that all uncommitted or in-flight
transactions will be cleaned up. The uncommitted transactions are
determined after the redo log is applied and automatically rolled
back.