Skip to Main Content
  • Questions
  • How to find out if a database exists in a given system

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question.

Asked: June 21, 2003 - 9:55 pm UTC

Last updated: March 12, 2024 - 8:05 am UTC

Version: 8.1.7

Viewed 10K+ times! This question is

You Asked

Tom

Suppose if a server is given to you , and you are asked to see if there is a database created( or in other words if a database exists in that server) or not, what is the quickest and what are the different ways in which you can find out( in both windows and unix).

Thanks in advance

Rag






and Tom said...

If a system was given to me and asked "is there a database on there", my answer would be "it is not relevant is it, cause you have no clue what data might be contained there in, so it is just bits and bytes"


There is no standard way -- no matter what you come up with, I'll show you 1,000 systems that do not conform to your approach.


On unix, there is an /etc/oratab - but many people (self included) ignore it and do not maintain it.

On windoze there are some registry entries -- but they may or may not point to an existing database.


Rating

  (23 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

listener, data files

Rag, June 22, 2003 - 11:36 am UTC

Well, some what dissapointing answer from the guru. If is do a lsnrctl status and it shows that the listener is listening, doesnt it prove that there is a database existing .

Further, what are the registry entries you are talking about on Windows, and what is the kind of information contained in oratabo on Unix.

Tom Kyte
June 22, 2003 - 1:35 pm UTC

No, you missed the point Rag.

I give you a server. Ok, now what, what are you going to do? Is the listener on port 1521? 1525 1234? 5231? which port? can you tell me? no, you cannot. How are you going to "status it"

And further, it shows there are services configured. It does not tell you "database there". It might, it might not.

And further, there could be a dozen databases on that server, none of which registered with that listener.

But even so -- you gotta find it first, so tell me, how are you going to find the listener?

If you have windows, open up your registry. I have no windows to look at. They are in there, under some Oracle key.

This is what an /etc/oratab might have:

[tkyte@tkyte-pc-isdn Desktop]$ cat /etc/oratab
#

# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.

# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
*:/usr/oracle/ora920/OraHome1:N

[tkyte@tkyte-pc-isdn Desktop]$

But mine is never kept upto date -- cause I don't use it.

listener!=database

W.Hwa Chan, June 22, 2003 - 12:20 pm UTC

you can start your listener service without any databases.
The question just likes give you a box with power cable unplugged, tell me what os has been installed? :)

Tom Kyte
June 22, 2003 - 1:37 pm UTC

zactly.

Hypothetical Scenario

Jack Wells, June 22, 2003 - 3:45 pm UTC

Tom,

<HAVINGFUN>
Suppose Larry called you tomorrow morning and said "Tom, the PeopleSoft deal just closed... we bought them! However, they used a scorched-earth policy in the data center, shutdown all 50 servers, and threw away all the documentation. Rag, my special agent in Pleasanton, has just spent the last 8 hours in their dumpster and cannot find any of the documentation. For reasons I can't disclose, I need to know what servers have Oracle database(s) on them and their names, version number, and size. Now, you need to keep this on the QT, so I want you to personally do it (I just fired Rag). I'll be there in my jet-fighter in two hours to pick you up... can you get this done in the next 24 hours? I'll be eternally greatful."
</HAVINGFUN>

Surely you wouldn't tell him his request is not relevant.

Tom Kyte
June 22, 2003 - 4:35 pm UTC


you'd only be able to "guess".

There isn't a single file you can look for.

don't say:

cd /
find . -name "init*.ora" -print


cause I'll give you the system that uses spfiles. Don't say, well look for either or. Cause I'll give you the system that the dba's always used "pfile=some_name" on the startup command (there are no init*.ora).

don't say look in /etc/oratab.

there is no 100% way -- sure I can list places to look

o look for init*.ora spfile*.ora -- they PROBABLY point to a database, at least you could try setting the oracle_home/sid to that and startup -- see if they do.

o look for /etc/oratab or use "control panel" to view services on nt (or regedit). that'll give you a list of maybes (but there could be hidden ones out there)

o see if you can find an rman respository ;)

o ps -auxww | grep pmon -- to see whats running.

guess that would be where I would start.


but really, give me a real business case.

to: Jack Wells

freek, June 22, 2003 - 4:40 pm UTC

Jack,

Which password are you going to use to log on?

Passwords... hmmm.

Jack Wells, June 22, 2003 - 4:53 pm UTC

Freek,

Good question! Hmmmm. I suppose if I have physical access to the box, I could call up HP, Microsoft, RedHat, and Sun to find out the backdoor way to reset the root password.

Not going to help you log onto Oracle

Jim, June 22, 2003 - 6:19 pm UTC

Getting root password isn't neccessarily going to help you log onto the Oracle database.

Tom Kyte
June 22, 2003 - 6:46 pm UTC

well, unless the system is really locked down -- su - oracle from root will get me in. won't need a password.

only if root is one of those neutered roots -- that don't have all of the privs would I be really stuck.

Even then, as long as I can copy the files -- to my own system (just need read for a moment), I got it.

So, actually, I might just mount the disks on my own system... forget their boot disk.

I'll tell you whats disappointing

Trevor Welch, June 23, 2003 - 12:00 am UTC

Hey Rag,

Pull your head in Pal...

I'll tell you what's disappointing that fact that
ungrateful people like you get to ask questions and others
more appreciative of Tom's time don't.

If this is your typical response to someone taking
the time to answer your questions for free and often
doing so in his own time then push off.

Tom I've said it before and I'll say it again.
There is a huge number of us who really appreciate
your asktom service.



Listner

Reaz, June 23, 2003 - 1:11 am UTC

I agree we need to appreciate Tom to provide us this valuable time, no question about it.

How do we register a listner to a database. Is it by configuring Listener file in Admin folder.

Best Regards.
Reaz/Dhaka

Tom Kyte
June 23, 2003 - 8:09 am UTC


typically, the database registers with a listener after the database starts up (show parameter listener at the sqlplus/svrmgrl prompt)


you can manually do it in the listener.ora file as well.

How to check from JSP/ASP?

Tony, June 23, 2003 - 2:27 am UTC

How to check wheather a DB is up or not from JSP or ASP?
Becoz I wanna give clear message saying "Database is down"



Tom Kyte
June 23, 2003 - 8:15 am UTC

try to connect.

if you get an ORA-1034, database is down.

to: Jack Wells

freek, June 23, 2003 - 2:57 am UTC

Doh !

From ASP / JSP

Abhijit, June 23, 2003 - 4:09 am UTC

Tony,
You would get an ORA-??? Listener not found on specified port error.

Cheers,


db alive?

Abdul Wahab, June 23, 2003 - 8:17 am UTC

hi TOm,
I don't know much about this command but i think i read about it some where...
Is there a command.. something like "sysresv" to find out details of database with out logging in it?


Tom Kyte
June 23, 2003 - 8:29 am UTC

not really details. it'll show some IPC stuff for running instances and even then only under the oracle home/oracle sid you happen to be in (meaning, you need to know the database is there in the first place and it has to already be running)

ORACLE_HOME/ORACLE_SID env variables

fan, June 23, 2003 - 10:59 am UTC

Doesn't any of these env variables or the existence of
Oracle installation directory (or ANY oracle dir) gives you a clue if have a db on that server ?

Thanks

Tom Kyte
June 23, 2003 - 11:19 am UTC

A db? maybe

50 db's? maybe

0 db's? maybe


an Oracle home says "there might be one" -- or there might not be, or there might be 50.

How to Check Oracle Instance on a system

Yong, June 23, 2003 - 12:53 pm UTC

Here is my way to do

On a window machine
1) go to control panel and click services to see any Oracle service exists
2) on a dos window type regedit to launch registry editor
3) in HKEY_LOCAL_MACHINE->SOFTWARE folder to check any Oracle folder exists
4) on a dos window do
if you are oracle or admin user
sqlplus /nolog
connect internal for Oracle 8i
or
connect /as sysdba for Oracle 9i
do some select
or startup/shutdown

If you have multiple Oracle Home, it need to do some more investigation.

ON Unix

do
1) more /var/opt/oracle/oratab for solaris
or
more /etc/oratab of other platform
2) you can also check /etc/rc2.d/auto_startup_scripts
3) ps -ef | grep ora_
or
ps -aux| grep ora_
4) ps -ef | grep oracle
or
ps -aux | grep oracle

Hope this help and save Tom's time


Dave, June 24, 2003 - 3:29 am UTC

that still wont tell you how many databases there are on the server, in fact the Unix one could return nothing and there could be 1000 instances on the server - it still hasnt helped you

Tom Kyte
June 24, 2003 - 7:47 am UTC

yeah, no matter how many times we say it -- it won't sink in.

Turn it off

Steve, June 24, 2003 - 5:50 pm UTC

for a few weeks then see if the phone rings from someone asking where their data's gone. If the phone don't ring then there ain't any data on there worth keeping!

Steve

/etc/oratab Replacements?

Sue, August 07, 2003 - 11:00 am UTC


>>This is what an /etc/oratab might have:

<snip>

>> But mine is never kept upto date -- cause I don't use it.

What do you use? I assume you have something somewhat equivalent, if for no other reason than shutting down or starting up all the various Oracle-related processes when the box boots (but perhaps that's an incorrect assumption).

What about anybody else? What do you use instead of /etc/oratab or /var/opt/oracle/oratab?


Tom Kyte
August 09, 2003 - 4:51 pm UTC

I use a database per machine :)

I just maintain an "orastart" and "orastop" script in $ORACLE_HOME/bin and maintain that manually. the etc/rc.d stuff just does

su -c oracle orastart


to get it going (that way, I don't have to bug 'root' to modify stuff. dbstart was way too limiting -- you want to start a listener (first) and only need one listener regardless of the number of machines. You then start the database(s). Maybe you need to fire up ctxsrv as well (interMedia) for some purpose, maybe you want to start up other daemons as well).

so, I just add to a very very simple script, that Oracle has 100% control over.

Again ...

Marcio Portes, August 05, 2004 - 11:20 am UTC

Hi Tom, you did again!!

Instead of
su - oracle -c orastart

you used
su -c oracle orastart

We forgive you ;)



reader

A reader, October 28, 2005 - 9:52 am UTC

someone had added an extra field 4th field on the oratab.

I was able to set the environment with oraenv
But when I tried to start the database, it was not even
"startup nomount". I was curious how the oratab content
affect starting up of the database

reader

A reader, October 28, 2005 - 3:56 pm UTC

9.2.0.6 unix

Tom Kyte
October 29, 2005 - 10:48 am UTC

the oratab isn't consulted by the startup command, not sure what you mean.

oratab is used by dbstart - you can review that script to see what it does and expects.

No entries in oratab

Chaman, December 28, 2007 - 8:57 am UTC

Hello Tom,
Even though we have 3 DBs on one Unix server, Im seeing only one DB entry on /var/opt/oratab file. Is it not mandatory to have all the DB names in oratab ?

Is there any other way where I can find out how many DBs are running (I know ps -ef | pmon would give) and what are the oracle homes of these DBs ?

Thanks
Tom Kyte
December 28, 2007 - 3:48 pm UTC

that oratab file is so "1980" if you ask me, I never use it or maintain it.

it is not necessary.

You sort of own the machine don't you? I mean, if you have some sort of configuration management in place, you'd know what databases you had.

If you use dbca to create a database, dbca will record it there, if you do not, or you did not have the privilege to write to it, it will not.

I guess you could do a find on "oracle" from / to find the oracle homes.

then ls in the dbs directory to see what pfiles you find.

but that would be about it - and if you do that, record what you find so you do not have to do that again and have people record what they do

Or use enterprise manager which - upon installing an agent on the machine - can discover instances.

what is equivalent to comman SYSRESV in WINDOWS

Yuna, January 23, 2008 - 2:04 pm UTC

Hi Tom,

I would like to know what is the equivalent command of SYSRESV in windows.

thank you very much!
Tom Kyte
January 23, 2008 - 2:24 pm UTC

it is:

C:\> echo Nothing to see here


there is no such thing as shared memory segments and the use of semaphores doesn't exist for us in a "unix way" on windows.

the "net services" command can show you want services (instances) you have running.

use LSOF for linux only

Pablo, March 08, 2024 - 2:47 pm UTC

This is what I do to check what is currently running on a specific db home. If nothing returns then this tells me nothing is using this particular db home. If something returns, I use the PID to investigate where is that PID coming from.

lsof | grep -e COMMAND -e /u01/app/oracle/product/19.0.0.0/dbhome_1
Connor McDonald
March 12, 2024 - 8:05 am UTC

An for windows users, SysInternals does Proc Explorer to allow a similar approach