Relationship between Oracle Database Name and Oracle Instance name

Source: Internet
Author: User
The Database Name (db_name) is the ID of a database, just like the ID card number of a person. If multiple databases are installed on one machine, each database has one database.

The Database Name (db_name) is the ID of a database, just like the ID card number of a person. If multiple databases are installed on one machine, each database has one database.

1 Database Name 1.1 concept of Database Name

The Database Name (db_name) is the ID of a database, just like the ID card number of a person. If multiple databases are installed on a machine, each database has a database name. After the database is installed or created, the parameter DB_NAME is written to the parameter file.

The database name is in $ Oracle_HOME/admin/db_name/pfile/init. ora (or $ ORACLE_BASE/admin/db_name/pfile/init. ora or $ ORACLE_HOME/dbs/SPFILE <实例名> . ORA) File

######################################## ###
# Database Identification
######################################## ###
Db_domain = ""
Db_name = orcl

When creating a database, you should consider the database name, and after the database is created, the database name should not be modified, even if you want to modify it will be very troublesome. Because the database name is also written into the control file and the control file is stored in binary format, you cannot modify the control file content. Assume that you have modified the database name in the parameter file, that is, the value of DB_NAME. But at Oracle startup, because DB_NAME In the parameter file is inconsistent with the database name in the control file, causing database startup failure, a ORA-01103 error is returned.

1.2 roles of database names

The database name must be used when installing the database, creating a new database, creating a database control file, modifying the data structure, backing up and restoring the database (note that sid cannot be used in these cases, also, the database name is used for alter database ).

Many Oracle installation file directories are related to database names, such:

Winnt: F: \ oracle \ product \ 10.2.0 \ oradata \ DB_NAME \...

Another example is the parameter file pfile:

Winnt: F: \ oracle \ product \ 10.2.0 \ admin \ DB_NAME \ pfile \ init. ora.54200885729

If the control file is damaged or lost, the database cannot be loaded. In this case, you need to re-create the control file by starting the instance in nomount mode, and then run the create controlfile command to create the control file, of course, DB_NAME must be specified in this command.

1.3 modify Database Name

Suggestion: the database name should be determined when the database is created. The database name should not be modified because it is complicated to modify the database name. It is the internal identifier for distinguishing data (that is, used internally by the Oracle database), because it is saved in multiple places in the database and saved in the control file is binary, so it is difficult to change its name.

After the data has been created, modify the database name. The procedure is as follows:
(1) shut down the database.
(2) modify the value of DB_NAME in the database parameter file to the new database name.
(3) Start the instance in NOMOUNT mode and build the control file (for the command syntax for creating the control file, refer to the oracle document)

1.4 query the current database name

Method 1: select name from v $ database;
Method 2: show parameter db
Method 3: view the parameter file $ ORACLE_HOME/admin/db_name/pfile/init. ora (or $ ORACLE_BASE/admin/db_name/pfile/init. ora)

2. database instance name 2.1 concept of database instance name (instance_name)

The instance name indicates the memory structures + Background process (MEM + BGP) used to load or open a database ). In unix, the Instance name is defined by the ORACLE_SID environment variable and by the service name in windows. It can be used in the connection string. This method is used before the 8i version. Although 10 Gb is still supported, it is not recommended because it lacks support for some new features.

An instance is a part of the computer memory and auxiliary processing background processes required to access the Oracle database. It is a collection of processes and the memory used by these processes (SGA, it does not need a database associated with it, and can start the instance without any data files. The Startup Process of Oralce is as follows:

Sqlplus/as sysdba
SQL> startup nomount # started an instance. Now the SGA instance is allocated, the process is running, and everything except the database is started.
SQL> alter database mount # use the control file (specified in the init. ora file) to locate and rebuild log files, data files, and temporary files
SQL> alter database open # The database can be accessed by anyone through this instance.

So it can be understood that accessing Oracle accesses an instance. However, if the instance is associated with a database file, it can be accessed. If it is not, the instance may be unavailable.

Instance name refers to the name of the database management system used to respond to a database operation, also known as SID. The instance name is determined by the instance_name parameter. If this parameter is not specified (instance_name is not specified as any value), the Instance name is determined by the user's environmental variable ORACLE_SID (note that this parameter is in upper case. On windows, the oracle_sid value in the registry is determined.

The instance name and SID are one-to-one correspondence, with the same name but different storage locations.

2.2 instances and databases

The differences between instances and databases are as follows:
(1) The instance is temporary and exists only when the related process and memory set exist; the database is permanent, as long as the file exists.
(2) A single database can be installed and opened for an instance within its lifetime. A database can be installed and opened by many instances, or installed and opened by one instance, or multiple instances can be installed and enabled simultaneously (RAC ).

In short, RAC is a system that enables multiple instances to open a database file at the same time. It is structured on multiple machines, and each machine runs one instance, each instance opens the same database (which is implemented by the disk sharing technology) and needs to synchronize high-speed cache between these instances to ensure that multiple instances are completely consistent, they do not conflict with each other or even overwrite each other.

The database instance name (instance_name) is used for external connections. To contact the database in the operating system, you must use the database instance name. For example, to connect to a database server, you must know its database instance name and only know the database name. Different from the database name, the Instance name can be modified after the data is installed or the database is created. The Database Name and Instance name can be the same or different. In general, the database name and Instance name are one-to-one, but in the oracle Parallel Server Architecture (that is, the oracle Real-time application cluster, the Database Name and Instance name are one-to-multiple relationships (one database corresponds to multiple instances, and users are only associated with one instance at a time. When an instance fails ,, other instances automatically serve to ensure the safe operation of the database ).

An instance is a group of operating system processes (or multi-threaded processes) and some memory. These processes can operate databases; the database is just a collection of files (including data files, temporary files, redo log files, and control files ). At any time, an instance can only have a group of related files (associated with a database ). In most cases, the opposite is true: only one instance in a database operates on it. However, Oracle's Application cluster (RAC) is an exception. This is an option provided by Oracle that allows operations on multiple computers in the cluster environment, in this way, multiple instances can simultaneously load and open a database (located on a group of shared physical disks ). Therefore, we can access the database from multiple computers at the same time. Oracle RAC supports highly available systems and can be used to build highly scalable solutions.

2.3 query the name of the current database instance

Method 1: select instance_name from v $ instance;
Method 2: show parameter instance

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.