Detecting if an Oracle Database is Installed
Asked Answered
M

6

9

I was wondering if there was a way to tell if an instance of Oracle on a system has a database installed or not?

This is for an installation script, and I need to verify that there is an actual database in place before proceeding with the loading of my own tablespace onto that database. Has anyone tackled this problem before?

Cheers

Milburn answered 20/11, 2008 at 11:1 Comment(0)
A
5

Check for the existence of an ORACLE_HOME. It's also reasonable to expect that this environment should be configured for the installation, so testing the environment variables and exiting with a sensible diagnostic (possibly suggesting they run oraenv) is a good first start. If you have an ORACLE_HOME, ORACLE_SID or other appropriate environment variable set up, you can then check for the existence of an oracle home and test for database connectivity and permissions.

Adrianadriana answered 20/11, 2008 at 11:7 Comment(3)
I just checked, I don't have an ORACLE_HOME or and ORACLE_SID and I can connect to Oracle databases without any problems whatsoever.Stationmaster
If you have instant client, then you do not need an oracle home... the connection string can be built right into the app and does not need oracle home or tsnames.oraNames
I think the OP was talking about a server - you can have instant client on a PC but a server will still have an oracle home for the database instance.Adrianadriana
C
6

For Oracle 10g, on Windows :

  • Check the registry :
    • The key HKLM\SOFTWARE\ORACLE must exist.
    • A subkey must exist that :
      • Has a name starting with KEY_ (like KEY_OraDb10g_home1, the end string being an Oracle home name).
      • Has a value whose name starts with ORA_ and ends with _AUTOSTART. (like ORA_XE_AUTOSTART, the middle string being an instance name).

Beware, installing an Oracle client (without a database instance then), creates entries in the registry and can set environment variables (like ORACLE_HOME). This is why the above pattern is a bit complicated.

This pattern is very likely to work for Oracle 9i also, and possibly Oracle 8i.

Calmas answered 20/11, 2008 at 18:49 Comment(2)
+1 for the Roadmap. Win32 Oracle client software generates an enormous body of garbage in the registry on installation.Adrianadriana
@Calmas I have tried to check the registry using following statement (C#): var swSubkeys = (Registry.LocalMachine.OpenSubKey("Software")).GetSubKeyNames(); but there is no ORACLE entry in swSubKeys (a string array). So I check using Regedit manually, obviously the ORACLE subkey exists in HKLM\SOFTWARE ... It is very confused.Sauternes
A
5

Check for the existence of an ORACLE_HOME. It's also reasonable to expect that this environment should be configured for the installation, so testing the environment variables and exiting with a sensible diagnostic (possibly suggesting they run oraenv) is a good first start. If you have an ORACLE_HOME, ORACLE_SID or other appropriate environment variable set up, you can then check for the existence of an oracle home and test for database connectivity and permissions.

Adrianadriana answered 20/11, 2008 at 11:7 Comment(3)
I just checked, I don't have an ORACLE_HOME or and ORACLE_SID and I can connect to Oracle databases without any problems whatsoever.Stationmaster
If you have instant client, then you do not need an oracle home... the connection string can be built right into the app and does not need oracle home or tsnames.oraNames
I think the OP was talking about a server - you can have instant client on a PC but a server will still have an oracle home for the database instance.Adrianadriana
S
4

You could use tnsping to check whether the database listener is active, that would be a good indication. Other than that, why not just simply do a test connection? If it's part of an installer process, you could prompt the user to enter the appropriate connection credentials if you don't know what they'll be in advance.

Stationmaster answered 20/11, 2008 at 11:5 Comment(0)
A
0

Look up the /etc/oratab file for oracle homes.These homes have the database software installed as well as the database name from that home.Then you can check whether the database is sound or not by starting it.

Altheaalthee answered 12/12, 2008 at 12:23 Comment(0)
P
0

For Windows people, here's how to check in Powershell.

Get-ChildItem -Path  HKLM:\\SOFTWARE\\ORACLE | Select-Object Name

Name
----
HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraDB12Home1

If you want to specifically test for the existence of the KEY_OraDB12Home1 key, you can do this in a Powershell script:

if (!(Test-Path 'HKLM:\\SOFTWARE\\ORACLE\\KEY_OraDB12Home1'))
{
  Write-Host "Oracle Database not found."   
} 
else 
{
  Write-Host "Oracle Database is installed. Starting...."
}
Pyxidium answered 3/3, 2023 at 16:36 Comment(0)
P
-1

I'm not sure about Oracle, but for MySQL and PostgreSql I do the following:

$yum grouplist | grep SQL

This returns:

MySQL Database client
MySQL Database server
PostgreSQL Database client
PostgreSQL Database server

So I assume you should try:

$yum grouplist | grep Orac
Pareira answered 9/1, 2013 at 21:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.