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
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.
For Oracle 10g, on Windows :
HKLM\SOFTWARE\ORACLE
must exist.KEY_
(like KEY_OraDb10g_home1
, the end string being an Oracle home name).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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With