Monday 7 March 2016

Oracle in Windows: ORADIM, the ORATAB equivalent

Working with Oracle in Windows can be tricky. There are certain environmental mechanisms in Linux that do not translate in the exact same manner within a Windows environment.

A key mechanism difference is the environment contextual switching and instance stopping and starting. In Linux, all we need to do is adjust the ORATAB file and add the database name and home.
We invoke the instance by using . oratab and enter our instance name.

In Windows, this is accomplished with the ORADIM utility. ORADIM is the one stop shop utility for stopping and starting database instances in a Windows environment. It also puts your database instance on the map, and by map I mean services.msc

If ORADIM is not used, you should see the following when attempting to access an instance without a corresponding windows service:
e:\Oracle\product\11.2.0.3\dbhome_1\BIN>set ORACLE_SID=MYDBSID 
e:\Oracle\product\11.2.0.3\dbhome_1\BIN>sqlplus /nolog

SQL*Plus: Release 11.2.0.3.0 Production on Tue Mar 8 08:17:04 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

SQL> conn / as sysdba
ERROR:
ORA-12560: TNS:protocol adapter error

SQL>

So, to put that instance on the map, you need to run the following command in cmd:

echo.
echo Creating a new instance service
oradim -new -SID MYDBSID -startmode manual -pfile 'E:\Oracle\Product\11.2.0.3\db_1\database\initMYDBSID.ora'

Once this has been done, and you've started the database up via services.msc (or manually), you can access the instance through the environment variable ORACLE_SID:
e:\Oracle\product\11.2.0.3\dbhome_1\BIN>set ORACLE_SID=MYDBSID 
e:\Oracle\product\11.2.0.3\dbhome_1\BIN>sqlplus /nolog

SQL*Plus: Release 11.2.0.3.0 Production on Tue Mar 8 08:18:47 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

SQL> conn / as sysdba
Connected.
SQL>

If you would like to remove an instance from the services management console:

echo.
echo Deleting an instance service
oradim -DELETE -SID MYDBSID 

Official documentation on ORADIM can be found below:
https://docs.oracle.com/database/121/NTQRF/create.htm#NTQRF05011

No comments:

Post a Comment