Oracle Instance name and service name, and database name differences

Source: Internet
Author: User
Tags oracle documentation

First, the database name
What is a database name?

The database name is the identity of a database, just like a person's ID number. He uses parameter db_name to indicate that if a machine is loaded with multiple databases, then each database has a database name. After the database installation or creation is complete, the parameter db_name is written to the parameter file. The format is as follows:
Db_name=myorcl
...
When you create a database, you should consider the name of the database, and after you create the database, the database name should not be modified, even if you want to modify it will be cumbersome. Because the database name is also written to the control file, the control file is stored in binary form and the user cannot modify the contents of the control file. Suppose the user modifies the database name in the parameter file, that is, modifies the value of the db_name. However, when Oracle starts, a ORA-01103 error is returned because the db_name in the parameter file is inconsistent with the database name in the control file, causing the database to fail to start.

Db_name and instance_name in the Init.ora file under \oracle\admin\szcg\pfile\, where SZCG is the database name

The role of database names
The database name is required to install the database, create a new database, create a database control file, modify the data structure, and back up and restore the database.
There are many Oracle installation file directories that are associated with database names, such as:
Winnt:d:\oracle\product\10.1.0\oradata\db_name\ ...
Unix:/home/app/oracle/product/10.1.0/oradata/db_name/...
Pfile
Winnt:d:\oracle\product\10.1.0\admin\db_name\pfile\ini.ora
Unix:/home/app/oracle/product/10.1.0/admin/db_name/pfile/init$oracle_sid.ora
Trace file directory:
Winnt:/home/app/oracle/product/10.1.0/admin/db_name/bdump/...
In addition, when creating data, the database name in the Careate DB command is also consistent with the value of the db_name parameter in the parameter file, or an error is generated.
Similarly, the statement that modifies the database structure alter the database and, of course, also indicate the name of the databases to be modified.
If the control file is corrupted or missing, the database will not load, and the control file must be recreated by starting the instance nomount and then creating the control file with the Create Controlfile command, which is also referred to as db_name.
There are also database names that need to be used when backing up or recovering a database.
In short, the database name is important to understand exactly what it does.

Querying the current data name
Method One: select name from V$database;
Method two: Show parameter db
Method Three: View the parameter file.

Select Global_name from Global_name;

Modify Database name
The previous recommendation: the database name should be determined when the database is created, and the database name should not be modified, because modifying the database name is a relatively complex thing. Now, let's explain how to modify the database name after the data has been created. The steps are as follows:
1. Close the database.
2. Modify the value of the db_name parameter in the database parameter file to the new database name.
3. Launch the instance in Nomount mode and build the control file (refer to Oracle Documentation for command syntax for creating control files)

Second, the database instance name
What is a DB instance name?
The database instance name is the identity used to contact the operating system, meaning the database instance name is used for interaction between the database and the operating system. The instance name is also written to the parameter file, which is instance_name, and the instance name is also written to the registry in the Winnt platform.
The database name and instance name can be the same or different.
In general, database names and instance names are a one-to-many relationship, but if you are in an Oracle Parallel server architecture (that is, Oracle real-time application clusters), the database name and instance name are a one-to-numerous relationship. This is illustrated in the first article in the legend.

Querying the current DB instance name
Method One: Select instance_name from V$instance;
Method Two: Show parameter instance
Method Three: Query in the parameter file.

UNIX can look like this:
$ ps-ef|grep Ora_
The last few letters of the process are SID

In the Oracle installation directory, such as D:/oracle/product/10.2.0/db_1/dbs, look at the file name such as Spfileorcl.ora, then is ORCL, that is, the file name is "spfile******." ORA, the kind of "* * * *" is SID

D:/oracle/product/10.2.0/oradata/sid Folder ...
or d:/oracle/product/10.2.0/db_1/dbs/spfilesid name. ORA

DB Instance name and Oracle_sid
Although both tables are Oracle instances, there is a difference between the two. Instance_name is an Oracle database parameter. ORACLE_SID is an environment variable for the operating system. Oracld_sid is used to interact with the operating system, that is, to access the instance name from the operating system's perspective and must pass ORACLE_SID. In the Winnt, Oracle_sid also needs to exist in the registry.
And the Oracle_sid must match the value of the instance_name, otherwise you will receive an error on the UNIX platform, which is "ORACLE not available" on the Winnt platform, which is "TNS: Protocol Adapter Error".

DB instance name and network connection
The database instance name is also used for the Oracle server identity of the network connection in addition to interacting with the operating system. When you configure the Oracle host connection string, you need to specify the instance name. Of course, the network components of 8i later require the service name service_name. This concept is explained next.

Third, the database domain name
What is a database domain name?

In distributed database systems, between different versions of the database server, regardless of whether the operating system is UNIX or Windows, each server can be remotely replicated through the database link, the database domain name is mainly used for replication in the Oracle distributed environment. Examples such as:
A distributed database of national transport and transportation systems, including:
Fujian node: Fj.jtyz
Xiamen, Fujian node: Xm.fj.jtyz
Jiangxi: Jx.jtyz
Shangrao, Jiangxi: Sr.jx.jtyz
This is the database domain name.
The database domain name exists in the parameter file, and his parameter is Db_domain.

Querying database domain names
Method One: SELECT * from v$parameter where name = ' Db_domain ';
Method two: Show parameter domain
Method Three: Query in the parameter file.

Global database name
Global database name = database name + database domain name, as described above the global database name for the Fujian node is: Oradb.fj.jtyz

Iv. Database service Name
What is the database service name?
Starting with the Oracle9i version, a new parameter, the database service name, was introduced. The name of the parameter is service_name.
If the database has a domain name, the database service name is the global database name; otherwise, the database service name is the same as the database name.

Querying database service Names
Method one: Show parameter service_name
Method Two: Query in the parameter file (check the database name).

Database service name and network connection
Oracle network components starting from Oracle8i, database and client connection host strings use the database service name. Previously used is ORACLE_SID, which is the database instance name.

Say, the default port number of the server is generally 389, the client default port number is generally 1521

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.