在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. Android版数据结构与算法(三):基于链表的实现LinkedList源码彻底分析

    版权声明:本文出自汪磊的博客,未经作者允许禁止转载. LinkedList 是一个双向链表.它可以被当作堆栈.队列或双端队列进行操作.LinkedList相对于ArrayList来说,添加,删除元素效 ...

  2. CentOS7中搭建cobbler自动装机服务

    一.实验环境 一台centos7 epel源网址 https://fedoraproject.org/wiki/EPEL?rd=Epel 使用nat模式 二.实验步骤 1.下载epel源后进行文件夹挂 ...

  3. PHP中反射的简单实用(动态代理)

    <?php class mysql{ function connect($db){ echo "连接mysql数据库${db[0]} \r\n"; } } class ora ...

  4. SAP HUM 锁住一个HU?

    SAP HUM 锁住一个HU? 1)SAP HUM 不能锁一个已发货的HU! 如下的HU 180141205000已经发货过账, HUMO, 执行, 2)一个WHSE状态的HU就可以被锁定.比如HU ...

  5. Android之RxJava详解

    文章大纲 一.什么是RxJava二.为什么要用RxJava三.RxJava使用详解四.项目源码下载五.参考文章 一.什么是RxJava   Rx(Reactive Extensions)是一个库,用来 ...

  6. SQL Server 数据库部分常用语句小结(三)

    21.SQL运行Log的读取 .EXEC xp_readerrorlog 0,1,null,null,'开始时间','结束时间' 22. Alwayson 状况及传输情况监控 SELECT ar.re ...

  7. Linux系统优化脚本

    #!/bin/bash ############################################################################## # File Na ...

  8. spring 【二】学习之spring EL

    spring EL-spring 表达式语言,支持在xml和注解的形式,类似于JSP的el表达式的形式. 其主要使用@Value注解的结构形式 其主要功能 [1].注入普通字符串 [2].注入操作系统 ...

  9. Python爬虫8-ajax爬取豆瓣影榜

    GitHub代码练习地址:https://github.com/Neo-ML/PythonPractice/blob/master/SpiderPrac12_ajax.py 了解ajax 是一种异步请 ...

  10. ansible基础-task控制

    1. 前言 很多情况下,一个play是否执行会依赖于某个(些)变量的值,这个变量可以来自自定义变量.facts,甚至是另一个task的执行结果. ansible通过变量判定task是否执行,我们称之为 ...