views:

977

answers:

5

Hi all,

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

+2  A: 

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.

ninesided
+2  A: 

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.

ConcernedOfTunbridgeWells
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.
ninesided
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.ora
jle
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.
ConcernedOfTunbridgeWells
A: 

Thanks guys, I'll take your suggestions into consideration and see how I do.

Cheers

C.McAtackney
Not an answer. Should be a comment.
Silence
+2  A: 

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.

Mac
+1 for the Roadmap. Win32 Oracle client software generates an enormous body of garbage in the registry on installation.
ConcernedOfTunbridgeWells
A: 

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.