Categories
Database vs. Instance Installing in the Cloud Oracle Certification and Database

Understanding oratab- Creating a Database

Oracle’s approach relies on two files: oratab and oraenv.

You can think of the entries in the oratab file as a registry of what databases are installed on a box and their corresponding Oracle home directories. The oratab file is automatically created for you when you install the Oracle software. On a Linux box, oratab is usually placed in the /etc/ directory. On Solaris servers, the oratab file is placed in the /var/opt/oracle directory. The oratab file is automatically created with the installation of the Oracle software and is automatically updated by the assistants such as DBCA. If it doesn’t get updated, it can get manually changed and updated.

The oratab file is used for the following purposes:

•     Automating the sourcing of required OS variables

•     Automating the start and stop of Oracle databases on the server

The oratab file has three columns with this format:

The Y or N indicates whether you want to restart automatically on reboot of the box; Y indicates yes, and N indicates no. Automating the startup and shutdown of your database is covered in detail in Chapter 20. Oracle srvctl also has management policies that are set for automatic restart of the databases that don’t use oratab.

Comments in the oratab file start with a pound sign (#). Here is a typical oratab file entry:

The name of the database is db23c with the ASM instance being +ASM. The path of each database’s ORACLE_HOME directory is next on the line separated from the database name by a colon [:]. Several Oracle-supplied utilities use the oratab file:

•     oraenv uses oratab to set the OS variables.

•     dbstart uses it to start the database automatically on server reboots if Y.

•     dbshut uses it to stop the database automatically on server reboots if Y.

The oraenv tool is discussed in the following section.

Using oraenv

If you don’t properly set the required OS variables for an Oracle environment, then utilities such as SQL*Plus, Oracle Recovery Manager (RMAN), and Data Pump will not work correctly. The oraenv script automates the setting of required variables such as ORACLE_HOME and ORACLE_SID on an Oracle database server. (If you are in a C shell environment, there is a corresponding coraenv utility).

The oraenv utility is located in the ORACLE_HOME/bin directory, and you run it manually:

$ . oraenv

Note that the syntax to run this from the command line requires a space between the dot (.) and the oraenv tool. You are prompted for ORACLE_SID, and if the ORACLE_SID is not in the oratab file, it will prompt for the ORACLE_HOME values:

ORACLE_SID = [orcl] ? ORACLE_HOME = [/u01/db23c] ?