Friday, April 6, 2012

Batch script for startup/shutdown Oracle under Windows

Under Windows environment Oracle offers ORADIM utility in order to manage your database: you can create, stop, start an instance using this command-prompt tool.

This can be invoked from $ORACLE_HOME\bin directory.

The shutdown script can look like this. Open and edit a notepad file, and save it with extension .bat:

$ORACLE_HOME\BIN\oradim -shutdown -sid YOUR_SID -syspwd YOUR_SYSPW -shuttype SRVC,INST -shutmode immediate
$ORACLE_HOME\BIN\lsnrctl stop

The startup script can look like this:
$ORACLE_HOME\BIN\lsnrctl start
$ORACLE_HOME\BIN\oradim -startup -sid YOUR_SID -syspwd YOUR_SYSPW -starttype SRVC,INST

The SRVC,INST refer to service and instance.

Below is the full option details available for oradim utility.

D:\app\hberca\product\11.2.0\dbhome_1\BIN>oradim -h
DIM-00002: The specified command was invalid.
Enter one of the following command:
Create an instance by specifying the following options:
     -NEW -SID sid | -SRVC srvc | -ASMSID sid | -ASMSRVC srvc [-SYSPWD pass]
 [-STARTMODE auto|manual] [-SRVCSTART system|demand] [-PFILE file | -SPFILE]
 [-SHUTMODE normal|immediate|abort] [-TIMEOUT secs] [-RUNAS osusr/ospass]
Edit an instance by specifying the following options:
     -EDIT -SID sid | -ASMSID sid [-SYSPWD pass]
 [-STARTMODE auto|manual] [-SRVCSTART system|demand] [-PFILE file | -SPFILE]
 [-SHUTMODE normal|immediate|abort] [-SHUTTYPE srvc|inst] [-RUNAS osusr/ospass]
Delete instances by specifying the following options:
     -DELETE -SID sid | -ASMSID sid | -SRVC srvc | -ASMSRVC srvc
Startup services and instance by specifying the following options:
     -STARTUP -SID sid | -ASMSID sid [-SYSPWD pass]
 [-STARTTYPE srvc|inst|srvc,inst] [-PFILE filename | -SPFILE]
Shutdown service and instance by specifying the following options:
     -SHUTDOWN -SID sid | -ASMSID sid [-SYSPWD pass]
 [-SHUTTYPE srvc|inst|srvc,inst] [-SHUTMODE normal|immediate|abort]
 Query for help by specifying the following parameters: -? | -h | -help

No comments:

Post a Comment