in reply to [OT] Get the database name in Oracle

You can't really mix your MySQL "show databases" concept with Oracle as the underlying philosophy is different. In MySQL a single engine is used to maintain all databases, but Oracle has a separate "engine" for each database - i.e. nothing is shared unless you have a clustered db - so the databases are independent of - and have no knowledge of - each other. As someone pointed out, the oratab file has a list of databases, but some may have been deleted and the oratab not changed to reflect it.
  • Comment on Re: [OT] Get the database name in Oracle

Replies are listed 'Best First'.
Re^2: [OT] Get the database name in Oracle
by kulls (Hermit) on Jan 03, 2006 at 09:22 UTC
    I can able to understand what you're saying and i don't know much about Oracle.
    if you look into the DBD::ORACLE ,
    use DBI; $dbh = DBI->connect("dbi:Oracle:$dbname",$user,$passwd);
    What's the meaning of  $dbname here ? . when i invoke sqlplus usr/pwd , then it entered into some database.i donno which one..Just i want to know before i put my hands on this.
    -kulls

      Well, in this context dbname isn't the name of your database, but a tnsname (which may be in a local tnsnames.ora file, your Oracle Names server or on an LDAP server). In other words the tnsname is a shorthand descriptor for the connection parameters to your database (including protocol, host or ip address, etc) It *may* (and usually does) have tha same name as your database, but this isn't required

      If all you want to do is get your connect name, it should be in $dbh->{Name} (I don't have ready access to Oracle at the moment, but I tested that it works for MySQL). Otherwise, get your DBA to give you access to v$database, and you can query the real db name from there.