Page 325
exit 4 fi # Now let's check to see if it came up. if [ -f "${ORACLE_HOME}/dbs/${ORACLE_SID}.dbf" ] then echo "The instance has now started." else echo "The instance is NOT started. Please check for errors " echo "before attempting to restart the database." exit 5 fi exit 0 ##################################
The code shown in Listing 14.2 is a sample shutdown script. This program is almost identical to the startup script, except that it uses shutdown.sql and reverses the logic in checking for the sgadef(instance).dbf file.
Listing 14.2. A sample UNIX script to shut down an Oracle instance.
#! /bin/sh ########## # filename: oracle_stop.sh ##### # As Oracle recommends, the first line is to force the script # to run in the Bourne Shell. ##### ##### # This script should be run from the Oracle DBA account. # It assumes that ORACLE_HOME has been defined. If it has not, # this script will exit with the appropriate error message. # # Other assumptions include that your ORACLE_SID has been set # before running this script. # ##### # If ORACLE_HOME = nothing then exit with a status of 1 if [ "${ORACLE_HOME}" = "" ] then echo "ORACLE_HOME is undefined. It must be defined before" echo "continuing." exit 1 fi # If ORACLE_SID is undefined, exit with a status of 2 if [ "${ORACLE_SID}" = "" ]
continues
Page 326
Listing 14.2. continued
then echo "ORACLE_SID is undefined. It must be defined before " echo "continuing." exit 2 fi # Check to see if the database is down # if the sgadef(instance).dbf file is not there, the instance is # not running and the shut down should exit if [ ! -f "${ORACLE_HOME}/dbs/${ORACLE_SID}.dbf" ] then echo "The ${ORACLE_SID} instance of Oracle is not currently echo "running. You must start up before you can shut down." exit 3 fi # The database is running, so let's do a normal shutdown # using the script we defined in the preceding sections. # If we cannot find sqldba, then we will exit with an error if [ -f "${ORACLE_HOME}/bin/svrmgrl" ] then svrmgrl @shutdown.sql else echo "Cannot locate svrmgrl. Cannot continue the shutdown." exit 4 fi # Now let's check to see if it was shut down if [ -f "${ORACLE_HOME}/dbs/${ORACLE_SID}.dbf" ] then echo "The instance is still running, or an error" echo "occurred while trying to shut down the instance." echo "Please refer to the alert log for any errors that" echo "might have occurred." exit 5 else echo "The instance was shut down." fi exit 0 ##########
This section contains Server Manager specific commands and their syntax. For more information on SQL*Plus specific commands, refer to Chapter 13, "SQL*Plus." The following commands are listed in alphabetical order.
Page 327
Description
The !, a shortcut for the HOST command, executes an operating system command or program while you're still in Server Manager. This command shells you out of Server Manager for the duration of the command. If issued by itself, it shells you to the operating system until you type EXIT or QUIT to return to Server Manager.
Command Syntax
HOST operating system command HOST ! operating system command !
Keywords
operating system command A valid operating system command or program.
Examples
HOST who; ! dir; HOST;
Description
The @ character is used to execute a script file containing SQL, PL/SQL, and DBA commands. It is used as a command-line option when calling Server Manager or from the SVRMGR> prompt, and it is followed by the name of the script file. If no name is specified, Server Manager prompts you for a file to execute.
Command Syntax
@filename
Keywords
filename Specifies the name of the script file to execute.
Examples
svrmgrl @shutdown_oracle.sql SVRMGR> @shutdown_oracle.sql
Page 328
Description
The ARCHIVE LOG command controls the starting and stopping of the automatic archiving of used redo logs and displays the current status of archive logging.
Command Syntax
ARCHIVE LOG LIST STOP START TO filename NEXT TO filename ALL TO filename integer TO filename
Keywords
LIST | Displays the current status of archive logging. The output includes log mode, automatic archival, archive destination, oldest online log sequence, next sequence to archive, and current sequence number. If the oldest online log sequence and current log sequence numbers are different, automatic archiving has been disabled or the previous log files have not been archived yet. |
START | Enables automatic archiving, which is controlled by the ARCH process. |
STOP | Disables automatic archiving. |
NEXT | Manually archives the next redo groups that have not been archived. |
ALL | Archives all redo groups that have not been archived. |
integer | Archives the log file with the sequence number integer stored in it. If the sequence number is invalid, an error is generated. |
filename | Refers to the instance-specific destination file or device to which the log files are to be written. |
Examples
ARCHIVE LOG LIST;
ARCHIVE LOG START;
ARCHIVE LOG 10982 `/u01/app/oracle/admin/dev/arch/dev'
Page 329
Description
You use the CONNECT command to connect to the database. Most Server Manager functions require the user to be connected before using them.
Command Syntax
CONNECT username/password CONNECT username/password@instance CONNECT / CONNECT INTERNAL
Keywords
username | The user ID to connect to. It must be a valid account. |
password | The password with which the account is identified. |
instance | The instance name or connect string of the destination instance. This can be the name of a database link, an alias created in SQL*Net 2, or the direct connect string specifying driver:system:instance_name. |
/ | A shortcut used to specify the default username/password when operating system authentication is used within the database. |
INTERNAL | A privileged logon used for many higher level commands such as startup and shutdown. This logon is an alias for SYS. |
Example
CONNECT INTERNAL;
CONNECT SYSTEM/MANAGER;
CONNECT /;
CONNECT SCOTT/TIGER;
Description
Used to describe database objects such as tables, views, procedures, packages, and package bodies. This command is available only when the user is connected to a database. This command can be abbreviated as DESC.