Search This Blog

Tuesday, June 10, 2008

Startup Database

You can start up and shut down your Oracle database through different interfaces.

Starting the Database

When you issue the startup command, Oracle will look for the initialization parameters in the default location, $ORACLE_HOME/dbs (UNIX). There, Oracle will look for the relevant files in the following order:

SPFILE$ORACLE_SID.ora

SPFILE.ora

Init$ORACLE_SID.ora




You can start the database in several modes. Let's take a quick look at the different options you have while starting up a database.

The Startup Nomount Command

You can start up the database with just the instance running by using the startup nomount command. The control files aren't read and the data files aren't opened when you open a database under this mode. The Oracle background processes are started up and the SGA is allocated to Oracle by the operating system. In fact, the instance is running by itself, rather like the engine of a tractor trailer being started with no trailer attached to the cab (you can't do much with either

SQL> connect / as sysdba

Connected to an idle instance.

SQL> startup nomount

ORACLE instance started.

Total System Global Area 156147688 bytes

Fixed Size 438248 bytes

Variable Size 146800640 bytes

Database Buffers 8388608 bytes

Redo Buffers 520192 bytes

What good does it do to have the database instance running without opening the data files for access? Well, sometimes during certain maintenance operations and during recovery times, you can't have the database open for public access. That's when this "partial open" of the database is necessary. During database creation and when you have to re-create control files, you use the nomount start-up option.

The Startup Mount Command

The next step in the database start-up process, after the instance is started, is the mounting of the database. This step reads the control file and mounts (i.e., connects) the data files to the database instance. You can do this in two ways. You can either use the alter database command to mount an already started instance, or you can use the startup mount command in the beginning, as shown in .

Sql> alter database mount;

Database altered.

Sql>

OR,

SQL> startup mount

ORACLE instance started.

Total System Global Area 156147688 bytes

Fixed Size 438248 bytes

Variable Size 146800640 bytes

Database Buffers 8388608 bytes

Redo Buffers 520192 bytes

Database mounted.

SQL>

During the mount stage, Oracle will associate the instance with the database. Oracle will open and read the control files, and get the names and locations of the data files and the redo log files. You usually need to start up a database in the mount mode when you're doing activities such as performing a full database recovery, changing the archive logging mode of the database, or renaming data files. Note that all three operations mentioned here require Oracle to access the data files, but can't accommodate any user operations in these files. Hence the opening of the database in the mount mode, with access to the general users still cut off.

The Startup Open Command

The last stage of the start-up process is the database open stage. The database is open for all users, not just the DBA. Prior to this stage, the general users can't connect to the database at all. You can bring the database into the open mode by issuing the alter database command as follows:

Sql> alter database open;

Database altered.

When the database is started in the open mode, all valid users can connect to the database and perform database operations. To open the database, the Oracle server will first open all the data files and the online redo log files and verify that the database is consistent. If the database isn't consistent—for example, if the SCNs in the control files don't match some of the SCNs in the data file headers—the background process will automatically perform an instance recovery before opening the database. If media recovery rather than instance recovery is needed, Oracle will signal that a database recovery is called for and won't open the database until you perform the recovery.



SQL> startup

ORACLE instance started.

Total System Global Area 156147688 bytes

Fixed Size 438248 bytes

Variable Size 146800640 bytes

Database Buffers 8388608 bytes

Redo Buffers 520192 bytes

Database mounted.

Database opened.

SQL>


No comments: