Oracle – How Does Oracle Close and Unmount a Database?

database-internalsoracleshutdown

I was reading the Oracle 12c concepts manual. Then I realised that something is not "technically" explained. Below is an excerpt of paragraph 13.2.2.2:

When a database is closed as part of a SHUTDOWN with any option other than ABORT,
Oracle Database writes data in the SGA to the data files and online redo log files. Next,
the database closes online data files and online redo log files
……
After the database is closed, Oracle Database unmounts the database to disassociate it
from the instance
.

I don't technically understand what happens for those two sentences in bold above. Any ideas?

I don't know the whole process but I believe that when a file is closed, the OS or the program takes it off the RAM. I can't quite align that with the bold sentences above.

Best Answer

It helps to understand what 'mount mode' means:

Before DB is mounted, instance is up (SGA and other memory structures are allocated but DB and its files etc have not been verified yet. In mount mode, the controlfile will be read, it will make sure all logfiles/datafiles etc are available and ready to go. This is essential maintenance. Then, after mounting, you open the db during which db will do additional checks including to see if any recovery is needed. Once these are done, DB is available for use.

So, during shutdown, once close is issued, Oracle will start stopping processes in a specific order. Then it flushes modifications data to tables, updates column usage metrics, bunch of internal tables, audits etc.

Then DB dismounts, i.e. opposite of mount, it checks for pending disk operations, completes them and then starts closing files, tells ASM to dissociates diskgroup from this instance. After this, archival process, logwriter stops.

So, when file headers are updated, controlfile is updated and file io stops the db is dismounted. All that remains are memory structures. once they are destroyed, DB instance is fully shutdown.

I am fairly certain someone can give you even more gritty details, but this should help you.