关于ORACLE数据库名以及数据实例名等几个重要概念
在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
关于ORACLE数据库名以及数据实例名等几个重要概念的更多相关文章
- 向Oracle数据库中插入数据出错:ORA-01036 无效的变量名或数据
向Oracle数据库中插入数据出错: 经过排查,因为Update数据时没有出错,所以OracleHelper没有问题: 看异常信息提示:无效的变量和数据,应该是SQL语句的问题,调试时所传的实例Use ...
- 数据库名(DB_NAME)、实例名(Instance_name)、以及操作系统环境变量(ORACLE_SID)
数据库名(DB_NAME).实例名(Instance_name).以及操作系统环境变量(ORACLE_SID) 在ORACLE7.8数据库中只有数据库名(db_name)和数据库实例名(instanc ...
- Oracle数据库间的数据复制 - SQLPlus中的COPY命令
Copy命令可以实现不同Oracle数据库间的数据的复制,也是可以实现同一数据库的数据复制,其性能表现和导入/导出相同. 根据9i文档,说Copy命令未来会不支持,但实际上Oracle 11g仍然支持 ...
- 将Oracle数据库中的数据写入Excel
将Oracle数据库中的数据写入Excel 1.准备工作 Oracle数据库"TBYZB_FIELD_PRESSURE"表中数据如图: Excel模板(201512.xls): 2 ...
- Oracle数据库中的数据出错的解决办法
http://www.jcwcn.com/article/database/oracle/ 今天上班犯了一个严重的错误:把我们系统所使用的Oracle数据库中的数据给改掉了!当发现自己改错时,顿时冒了 ...
- 160316、实时处理oracle数据库中表的数据变化
http://blog.csdn.net/as339000204/article/details/45390727 近期接受项目需求,需要实时处理oracle数据库中表的数据变化,首先想到的是 ...
- ArcCatalog中通过ArcSDE向Oracle数据库中导入数据
将数据导入到Oracle指定的表空间的具体内容如下: 首先,在ArcCatalog中建立指定表空间的数据库连接(要以指定表空间的用户登录): 然后,在ArcCatlog中定位到数据源,选中并拷贝图层; ...
- oracle数据库的导入 导出实例
oracle数据库的导入 导出实例 分类: DataBase2011-09-07 23:25 377人阅读 评论(0) 收藏 举报 数据库oraclefileusercmdservice 我要从另外一 ...
- Oracle数据库四种数据完整性约束
Oracle数据库四种数据完整性约束 1.实体完整性 同样的数据不能重复插入(1)采取什么措施保证实体完整性?我们可以给表创建主键约束吗,主键保证了数据的唯一性,主键可以保证同一条记录只能插入一次. ...
随机推荐
- 从0开始构建你的api网关--Spring Cloud Gateway网关实战及原理解析
API 网关 API 网关出现的原因是微服务架构的出现,不同的微服务一般会有不同的网络地址,而外部客户端可能需要调用多个服务的接口才能完成一个业务需求,如果让客户端直接与各个微服务通信,会有以下的问题 ...
- 工程文件csproj使用编译条件指定属性
csproj工程文件中有很多xml格式的属性,比如PropertyGroup.ItemGroup,某些属性操作默认是全部的或者是当前编译条件的而已,当我们想指定某些属性只在某个编译条件下发生时就可以通 ...
- PyCharm 如何远程连接服务器编写程序
写在前面 我之前一直通过mstsc远程服务器桌面修改代码,或者本地修改后上传到远程服务器等,各种不爽,现在改用xshell,但有时候还是感觉不方便.于是乎,自己动手配置PyCharm远程连接服务器,这 ...
- Sql中CHARINDEX用法
CHARINDEX作用 写SQL语句我们经常需要判断一个字符串中是否包含另一个字符串,但是SQL SERVER中并没有像C#提供了Contains函数,不过SQL SERVER中提供了一个叫CHAEI ...
- Java中char,short,int,long占几个字节和多少位
1.字节:byte:用来计量存储容量的一种计量单位:位:bit 2.一个字节等于8位 1byte = 8bit char占用的是2个字节 16位,所以一个char类型的可以存储一个汉字. 整型: b ...
- iOS 11: CORE ML—浅析
本文来自于腾讯Bugly公众号(weixinBugly),未经作者同意,请勿转载,原文地址:https://mp.weixin.qq.com/s/OWD5UEiVu5JpYArcd2H9ig 作者:l ...
- “Validation failed for one or more entities”异常的解决办法
日志中出现Entity Framework修改数据库时的错误: Validation failed for one or more entities. See 'EntityValidationErr ...
- cxf 整合 spring 时 java.lang.VerifyError异常
异常信息主要有两个,Falling off the end of the code 和 illegal instruction found at offset 1: java.lang.VerifyE ...
- Java核心技术第五章——2.Object类
Object类:所有类的超类 Object类是Java中所有类的始祖,在Java中每个类都是由它扩展而来的.但是并不需要这样写: public class Emloyee extends Object ...
- Java数据结构和算法 - OverView
Q: 为什么要学习数据结构与算法? A: 如果说Java语言是自动档轿车,C语言就是手动档吉普.数据结构呢?是变速箱的工作原理.你完全可以不知道变速箱怎样工作,就把自动档的车子从1档开到4档,而且未必 ...