How to see list of databases in Oracle?

Is there an equivalent to MySQL SHOW DATABASES statement?

There is no such thing. You can query listeners on a machine (lsnrctl status) to see what services are registered there, but that doesn't map one-to-one to database (and there could be multiple listeners on the same machine). Otherwise, the tools commonly used connect to one database instance, and an instance belongs to a single database.

If you're talking about Oracle RAC clusters, then each instance knows of its peers (other instances that service the same database) and you can find the other instances currently started for that database using the gv$instance view.
You can also use the crsctl utility to list the services (including databases) that are registered in the cluster, and their status.
If you're talking about another vendor's clustering software, I'm pretty sure they all have these types of resource management utilities to query.

If you're talking about just a bunch of machines, then no, there's no 100% reliable way of enumerating all databases on a network.

To find active (i.e. started) databases, look for *_pmon_* processes on Unix (there's one per database instance), and Oracle services on Windows.

To locate installations of Oracle database software, look at /etc/oratab on Unix. This should contain all the ORACLE_HOMEs installed. You can look inside each of those in $ORACLE_HOME/dbs for spfile<SID>.ora and/or init<SID>.ora files - there will be one for each database.

(I believe you can find the equivalent of the information in oratab in the Windows registry keys below HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE, but I don't know its structure.)

Now, of course, if you've registered all your database with an OEM (Enterprise Manager) server when you installed them, you can find the complete list there - but I guess if you're asking that's not the case.


Oracle has no databases but schemas, you can list them with

SELECT USERNAME FROM ALL_USERS ORDER BY USERNAME; 

or something like this :

SELECT TABLESPACE_NAME FROM USER_TABLESPACES;

Simply speaking, there is no direct analogy for MySQL 'databases' or a 'cluster' on Oracle: the closest match is a 'schema' but that is still very different.

This is apparently going to change in 12c with the introduction of pluggable databases:

Dividing the database operations cleanly from the user's content is a major transformation from traditional database architectures. Oracle 11g, and all its predecessors, could only run one database at a time, Kyte said. If an organization wanted to run multiple databases on a single server, it would need to run multiple instances of Oracle 11g, one for each database. As the name implies, pluggable databases allow multiple tenant databases to run under one copy of Oracle 12c.

Tags:

Oracle