标签:... bool oci null com value ann ble detail
在Oracle中有关数据库和数据库实例的几个重要概念,有时候如果理解不是很深或者对其疏忽、混淆了,还真容易搞错或弄不清其概念,下面就数据库实例名、数据库名、数据库域名、数据库服务名、全局数据库名几个概念,我们来梳理一下概念,总结归纳一下这些知识,首先,我们来看看官方文档对这几者的概念介绍:
INSTANCE_NAME(数据库实例名)
Property | Description |
Parameter type | String |
Syntax | INSTANCE_NAME = instance_id |
Default value | The instance‘s SID Note: The SID identifies the instance‘s shared memory on a host, but may not uniquely distinguish this instance from other instances. |
Modifiable | No |
Range of values | Any alphanumeric characters |
Basic | No |
In a Real Application Clusters environment, multiple instances can be associated with a single database service. Clients can override Oracle‘s connection load balancing by specifying a particular instance by which to connect to the database. INSTANCE_NAME specifies the unique name of this instance.
In a single-instance database system, the instance name is usually the same as the database name.
Oracle Instance是指一组后台进程(在Windows上是一组线程)和一块共享内存区域。实例名(instance_name)就是用来标识这个instance的一个名称而已。
DB_NAME(数据库名)
Property | Description |
Parameter type | String |
Syntax | DB_NAME = database_name |
Default value | There is no default value. |
Modifiable | No |
Basic | Yes |
Real Application Clusters | You must set this parameter for every instance. Multiple instances must have the same value, or the same value must be specified in the STARTUP OPEN SQL*Plus command or the ALTER DATABASE MOUNT SQL statement. |
DB_NAME specifies a database identifier of up to 8 characters. This parameter must be specified and must correspond to the name specified in the CREATE DATABASE statement.
If you have multiple databases, the value of this parameter should match the Oracle instance identifier of each one to avoid confusion with other databases running on the system. The value of DB_NAME should be the same in both the standby and production initialization parameter files.
The database name specified in either the STARTUP command or the ALTER DATABASE ... MOUNT statement for each instance of the cluster database must correspond to the DB_NAME initialization parameter setting.
The following characters are valid in a database name: alphanumeric characters, underscore (_), number sign (#), and dollar sign ($). No other characters are valid. Oracle removes double quotation marks before processing the database name. Therefore you cannot use double quotation marks to embed other characters in the name. The database name is case insensitive.
DB_NAME Initialization Parameter
DB_NAME must be set to a text string of no more than eight characters. During database creation, the name provided for DB_NAME is recorded in the datafiles, redo log files, and control file of the database. If during database instance startup the value of the DB_NAME parameter (in the parameter file) and the database name in the control file are not the same, the database does not start.
简单来说,数据库名是数据库的名称标识,它是在创建数据库的时候确定的,一旦确定,不能更改。该信息存在于初始化文件,控制文件、redo log文件以及数据文件等地方。
DB_DOMAIN(数据库域名)
Property | Description |
Parameter type | String |
Syntax | DB_DOMAIN = domain_name |
Default value | There is no default value. |
Modifiable | No |
Range of values | Any legal string of name components, separated by periods and up to 128 characters long (including the periods). This value cannot be NULL. |
Basic | Yes |
Real Application Clusters | You must set this parameter for every instance, and multiple instances must have the same value. |
In a distributed database system, DB_DOMAIN specifies the logical location of the database within the network structure. You should set this parameter if this database is or ever will be part of a distributed system. The value consists of the extension components of a global database name, consisting of valid identifiers (any alphanumeric ASCII characters), separated by periods. Oracle recommends that you specify DB_DOMAIN as a unique string for all databases in a domain.
This parameter allows one department to create a database without worrying that it might have the same name as a database created by another department. If one sales department‘s DB_DOMAIN is JAPAN.ACME.COM, then their SALES database (SALES.JAPAN.ACME.COM) is uniquely distinguished from another database with DB_NAME = SALES but with DB_DOMAIN = US.ACME.COM.
If you omit the domains from the name of a database link, Oracle expands the name by qualifying the database with the domain of your local database as it currently exists in the data dictionary, and then stores the link name in the data dictionary. The characters valid in a database domain name are: alphanumeric characters, underscore (_), and number sign (#).
在分布式数据库系统中,定义一个数据库所在的域,该域的命名同互联网的’域’没有任何关系,只是数据库管理员为了更好的管理分布式数据库而根据实际情况决定的。当然为了管理方便,可以将其等于互联网的域。本来db_name用来对一个数据库的唯一标识,这种表示对于单个数据库是足够的,但是随着由多个数据库构成的分布式数据库的普及,这种命名数据库的方法给数据库的管理造成一定的负担,因为各个数据库的名字可能一样,造成管理上的混乱。为了解决这种情况,引入了db_domain参数,这样在数据库的标识是由 db_name和db_domain两个参数共同决定的,避免了因为数据库重名而造成管理上的混乱。这类似于互连网上的机器名的管理.
GLOBAL_NAMES
Property | Description |
Parameter type | Boolean |
Default value | false |
Modifiable | ALTER SESSION, ALTER SYSTEM |
Range of values | true | false |
Basic | No |
GLOBAL_NAMES specifies whether a database link is required to have the same name as the database to which it connects.
If the value of GLOBAL_NAMES is false, then no check is performed. If you use or plan to use distributed processing, then Oracle recommends that you set this parameter to true to ensure the use of consistent naming conventions for databases and links in a networked environment.
global database name(全局数据库名)
1. What is a global database name?
------------------------------------------------------------------------------
The global database name is the unique name of the database. In a distributed
database system (a set of databases stored on multiple computers that typically
appears to applications as a single database) the global database name ensures
that each database is distinct from all other databases in the system. Oracle
forms a database‘s global database name by prefixing the database‘s network
domain with the individual database‘s name. For example: sales.us.oracle.com
and sales.uk.oracle.com.
The global database name defaults to DB_NAME.DB_DOMAIN and this value is marked
at database creation time. If you change the DB_NAME or DB_DOMAIN after the
database has been created, the value for the global database name (GLOBAL_NAME)
will not change.
Understanding How Global Database Names Are Formed
A global database name is formed from two components: a database name and a domain. The database name and the domain name are determined by the following initialization parameters at database creation:
Component | Parameter | Requirements | Example |
Database name | DB_NAME | Must be eight characters or less. | sales |
Domain containing the database | DB_DOMAIN | Must follow standard Internet conventions. Levels in domain names must be separated by dots and the order of domain names is from leaf to root, left to right. |
|
说简单一点,global database name就是用来唯一标识数据库的概念。Oracle的GLOBAL_NAME由两个部分组成:DB_NAME和DB_DOMAIN。如果在建立数据库的时候不指定DB_DOMAIN的值,则GLOBAL_NAME和DB_NAME的值一样。
注意:不管是设置通过DB_DOMAIN的方式,还是通过ALTER DATABASE RENAME GLOBAL_NAME TO的方式。一旦GLOBAL_NAME包含了DB_DOMAIN部分。就再也无法去掉了(可以更新SYS.PROPS$ 解决,不推荐)
SERVICE_NAMES
Property | Description |
Parameter type | String |
Syntax | SERVICE_NAMES = db_service_name [, db_service_name [ ... ] ] |
Default value | DB_UNIQUE_NAME.DB_DOMAIN if defined |
Modifiable | ALTER SYSTEM |
Range of values | Any ASCII string or comma-separated list of string names |
Basic | No |
Real Application Clusters | Do not set the SERVER_NAMES parameter for Real Application Clusters (RAC). Instead, define services using Database Configuration Assistant (DBCA) and manage services using Server Control (SRVCTL) utility. |
SERVICE_NAMES specifies one or more names by which clients can connect to the instance. The instance registers its service names with the listener. When a client requests a service, the listener determines which instances offer the requested service and routes the client to the appropriate instance.
You can specify multiple service names in order to distinguish among different uses of the same database. For example:
SERVICE_NAMES = sales.acme.com, widgetsales.acme.com
You can also use service names to identify a single service that is available from two different databases through the use of replication.
If you do not qualify the names in this parameter with a domain, Oracle qualifies them with the value of the DB_DOMAIN parameter. If DB_DOMAIN is not specified, then no domain will be applied to the non-qualified SERVICE_NAMES values.
该参数是Oracle 8i新引进的。在8i以前,我们用SID来表示标识数据库的一个实例,但是在Oracle的并行环境中,一个数据库对应多个实例,这样就需要多个网络服务名,设置繁琐。为了方便并行环境中的设置,引进了SERVICE_NAME参数,该参数对应一个数据库,而不是一个实例,而且该参数有许多其它的好处。该参数的缺省值为db_name.db_domain,即等于GLOBAL_NAME。一个数据库可以对应多个service_name,以便实现更灵活的配置。该参数与SID没有直接关系,即不必service name必须与SID一样。
服务名(service_names):指listener提供的对外的服务名,客户端可以通过配置tnsnmaes.ora连进行连接,tnsnmaes.ora文件中的service_name要等于服务器端listener所注册的服务名,服务名可以通过输入lsnrctl后,在输入service查看,一般的service_name在listener.ora文件中配置(静态注册),或者当没有listener.ora文件时,在初始化文件中配置instance_name和service_names这2个参数进行动态注册。但是无论采用那种注册方式,都可以通过lsnrctl-sevice来检查。
查看当前数据库名
方法1:
SQL> show parameter db_name;
方法2:查询数据库视图
SQL> select name from v$database;
方法3:查看参数文件
查看数据库实例名
方法1:
SQL> show parameter instance_name;
方法2:查询数据库视图
SQL> select instance_name from v$instance;
查看数据库域名
方法1:
SQL> show parameter db_domain;
方法2:
select value from v$parameter where name=‘db_domain‘;
查看数据库服务名
方法1:
SQL> show parameter service_name;
查看全局数据库名
SQL> SELECT * FROM GLOBAL_NAME;
SID与SERVICE_NAME的区别
instance_name是Oracle数据库参数。而ORACLE_SID是操作系统的环境变量。 数据库实例启动后select instance_name from v$instance;这个时候我们可以看到instance_name和在环境变量里面配置的ORACLE_SID是同样的名称。(注:正是由于这个原因,我们一般说的SID就是instance_name,但是需要注意的是,实际上instance_name不等于ORACLE_SID。前者是数据库层面的概念,后者是操作系统中环境变量的设置。)
ORACLE_SID is used to distinguish this instance from other Oracle Database instances that you may create later and run concurrently on the same host computer. The maximum number of characters for ORACLE_SID is 12, and only letters and numeric digits are permitted. On some platforms, the SID is case-sensitive.
参考资料:
https://gerardnico.com/db/oracle/global_name
https://docs.oracle.com/cd/B28359_01/server.111/b28320/initparams059.htm#REFRN10041
https://blog.csdn.net/tanwen1234/article/details/11991743
https://yq.aliyun.com/articles/248995
https://docs.oracle.com/cd/B28359_01/server.111/b28310/ds_admin001.htm#BEGIN
标签:... bool oci null com value ann ble detail
原文地址:https://www.cnblogs.com/kerrycode/p/10230982.html