Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Tips Database Forum Rss Feed

» Database Journal Home
» Database Articles
» Database Tutorials
MS Access
SQL Scripts & Samples
» Database Forum
» Slideshows
Free Newsletters:

News Via RSS Feed

Rss Feed

Database Journal |DBA Support |SQLCourse |SQLCourse2

Featured Database Articles


Posted Sep 4, 2003

What's In A Name - Naming and Idenifying Oracle Databases and Instances

By James Koopmann

Identification of the database you are currently working on can sometimes be somewhat confusing. Take a look at the internal parameters that Oracle keeps and see if you can uniquely identify the database you are currently working on.

A big problem in the Oracle database world is the initialization and setup of naming conventions within the Oracle database. There are quite a few DBA(s) that approach this with a lackadaisical attitude. It is not until they find themselves in a distributed field of databases that they soon begin to loose their mind and wonder where and what database they are working on. Let's take a quick look at the handful of parameters that need to be set and at the same time take a look at how we can determine what database and instance we are working on and connected to.


The DB_NAME parameter is the value of the database and is the name used when creating the database. It is specified within the INIT.ORA parameter file or in the CREATE DATABASE command. This is one of those parameters that is optional but is always best to set it. This is especially true for the standby database where it should match the production database. You can look at this parameter by issuing the SQL in Listing 1.

Listing 1

HCMC-SQL> select name , value from v$parameter where name = 'db_name';

NAME                 VALUE

-------------------- --------------------------------------------------

db_name              hcmc


DB_DOMAIN is the value of the domain to which the database belongs. It is the location of the database within the network hierarchy. Even if the database you are creating is not going to be a part of any network or distributed system, I would suggest that you set this parameter just for the sake of going through the thought process and understanding how things connect when networked. I personally always set up my net services for my local boxes that are not ever going to be connected to another database. You might ask why? Well I have never created a database that I 'did not want to be part of a distributed system after I played with it for a bit. After all, it will keep you in good practice of these configuration parameters. You can look at this parameter by issuing the SQL in Listing 2.

Listing 2

HCMC-SQL> select name , value from v$parameter where name = 'db_domain';

NAME                 VALUE

-------------------- --------------------------------------------------

db_domain den.dbdoctor.net


This little gem has always been at the top of my list for determining what database I am connected to. This is the parameter that everyone use to use to query and set the prompt for in SQL*PLUS to give a unique identity to the SQL*PLUS session currently active. This parameter is a combination of the DB_NAME parameter and the DB_DOMAIN parameter. The simple SQL in Listing 3 will show you how to get this value. If you are curious how you can set the SQL*PLUS prompt, just issue the SQL in Listing 4. While I 'would not quite recommend this for anything other than a single node instance on a database, it does work quite well if you have unique GLOBAL_NAME(s) within your organization.

Listing 3
SQL for global_name extraction

SQL> select * from global_name;


Listing 4
Setting the SQL*PLUS prompt

column gname new_value dname noprint 
select substr(global_name,1,instr(global_name,'.')-1) gname from global_name;
define prmpt='&&dname'
set sqlprompt "&&prmpt-SQL> "

Oracle Archives

Latest Forum Threads
Oracle Forum
Topic By Replies Updated
Oracle Data Mining: Classification jan.hasller 0 July 5th, 07:19 AM
Find duplicates - Unique IDs Lava 5 July 2nd, 08:30 AM
no matching unique or primary key rcanter 1 April 25th, 12:32 PM
Update values of one table based on condition of values in other table using Trigger Gladiator 3 February 29th, 06:01 PM