在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数据库名以及数据实例名等几个重要概念的更多相关文章

  1. 向Oracle数据库中插入数据出错:ORA-01036 无效的变量名或数据

    向Oracle数据库中插入数据出错: 经过排查,因为Update数据时没有出错,所以OracleHelper没有问题: 看异常信息提示:无效的变量和数据,应该是SQL语句的问题,调试时所传的实例Use ...

  2. 数据库名(DB_NAME)、实例名(Instance_name)、以及操作系统环境变量(ORACLE_SID)

    数据库名(DB_NAME).实例名(Instance_name).以及操作系统环境变量(ORACLE_SID) 在ORACLE7.8数据库中只有数据库名(db_name)和数据库实例名(instanc ...

  3. Oracle数据库间的数据复制 - SQLPlus中的COPY命令

    Copy命令可以实现不同Oracle数据库间的数据的复制,也是可以实现同一数据库的数据复制,其性能表现和导入/导出相同. 根据9i文档,说Copy命令未来会不支持,但实际上Oracle 11g仍然支持 ...

  4. 将Oracle数据库中的数据写入Excel

    将Oracle数据库中的数据写入Excel 1.准备工作 Oracle数据库"TBYZB_FIELD_PRESSURE"表中数据如图: Excel模板(201512.xls): 2 ...

  5. Oracle数据库中的数据出错的解决办法

    http://www.jcwcn.com/article/database/oracle/ 今天上班犯了一个严重的错误:把我们系统所使用的Oracle数据库中的数据给改掉了!当发现自己改错时,顿时冒了 ...

  6. 160316、实时处理oracle数据库中表的数据变化

    http://blog.csdn.net/as339000204/article/details/45390727     近期接受项目需求,需要实时处理oracle数据库中表的数据变化,首先想到的是 ...

  7. ArcCatalog中通过ArcSDE向Oracle数据库中导入数据

    将数据导入到Oracle指定的表空间的具体内容如下: 首先,在ArcCatalog中建立指定表空间的数据库连接(要以指定表空间的用户登录): 然后,在ArcCatlog中定位到数据源,选中并拷贝图层; ...

  8. oracle数据库的导入 导出实例

    oracle数据库的导入 导出实例 分类: DataBase2011-09-07 23:25 377人阅读 评论(0) 收藏 举报 数据库oraclefileusercmdservice 我要从另外一 ...

  9. Oracle数据库四种数据完整性约束

     Oracle数据库四种数据完整性约束 1.实体完整性 同样的数据不能重复插入(1)采取什么措施保证实体完整性?我们可以给表创建主键约束吗,主键保证了数据的唯一性,主键可以保证同一条记录只能插入一次. ...

随机推荐

  1. <<C语言--神奇的指针>>

    指针很简单 ------引子 学计算机语言,首先推荐C语言.无论是数据结构还是算法,站在C语言的角度,会让我们理解的更加清晰透彻. 但是,指针不太"友好",让很多人抓狂,头疼.不少 ...

  2. 设计模式 | 策略模式(strategy)

    参考:https://www.cnblogs.com/lewis0077/p/5133812.html(深入解析策略模式) 定义: 策略模式定义了一系列的算法,并将每一个算法封装起来,使每个算法可以相 ...

  3. (三)图数据库neo4j的安装配置

    (一)neo4j安装 neo4j有社区版本和企业版,社区版本是免费的,企业版本是收费的.在linux上安装如下步骤: 1.将下载的neo4j-enterprise-3.4.0-unix.tar.gz包 ...

  4. uboot的驱动模型理解

    uboot的驱动模型,简称dm, 具体细节建议参考./doc/driver-model/README.txt 关于dm的三个概念: uclass:一组同类型的devices,uclass为同一个gro ...

  5. Exp4恶意代码分析 20164312 马孝涛

    1.实践目标 1.1是监控你自己系统的运行状态,看有没有可疑的程序在运行.  1.2是分析一个恶意软件,就分析Exp2或Exp3中生成后门软件:分析工具尽量使用原生指令或sysinternals,sy ...

  6. 如何让 Editplus 支持 SQL 语法高亮

    editplus 用来编辑或查看一些常用程序源码都很方便,而且软件小巧,但是他原生不能支持对 SQL 文件的高亮显示,有点遗憾,但好在我们可以自定义这种高亮显示,那么要如何设置呢 1. 首先点击下载文 ...

  7. qml demo分析(clocks-时钟)

    一.效果展示 效果如图1所示,时钟列表支持鼠标左右拖动,带有黑色背景的是晚上时钟,无黑色背景的是白天时钟 二.源码分析 1.main.cpp文件中只包含了一个宏,该宏的具体解释请看qml 示例中的关键 ...

  8. 【链表问题】打卡9:将单链表的每K个节点之间逆序

    前言 以专题的形式更新刷题贴,欢迎跟我一起学习刷题,相信我,你的坚持,绝对会有意想不到的收获.每道题会提供简单的解答,如果你有更优雅的做法,欢迎提供指点,谢谢. 注:如果代码排版出现了问题麻烦通知我下 ...

  9. LVS (一) 原理

    LVS原理概述 负载均衡就是,在多个提供相同服务主机的前段,增加一个分发器,根据用户请求,然后根据某种方式或者策略,将用户请求分发到提供服务的主机上.同时负载均衡应用还应该提供对后其后端服务健康检查的 ...

  10. OA发展史:由点到生态

    在当今无边界组织的商业背景下,企业与员工关系已经转化为联盟关系,以往通过工作场所.劳动合同等约束的形式已经逐步弱化,管理行为空前复杂,OA正是将一个个散点整合起来的看不见的手.那么,推动OA发展的核心 ...