• Overview of Database Link数据库链接概述


    什么是数据库链接?

    数据库链接是一个指针,它定义了从 Oracle 数据库服务器到另一个数据库服务器的单向通信路径。

    对于公共和私有数据库链接,链接指针实际上被定义为数据字典表中的条目。要访问该链接,您必须连接到包含数据字典条目的本地数据库。对于全局数据库链接,链接指针在目录服务中定义。“数据库链接的类型”中 更详细地描述了不同类型的数据库链接

    数据库链接连接是单向的,即连接到本地数据库 A 的客户端可以使用存储在数据库 A 中的链接访问远程数据库 B 中的信息,但连接到数据库 B 的用户不能使用相同的链接访问远程数据库 B 中的数据数据库 A。如果数据库 B 上的本地用户想要访问数据库 A 上的数据,那么他们必须定义一个链接,该链接存储在数据库 B 的数据字典中。

    数据库链接连接允许本地用户访问远程数据库上的数据。为了发生这种连接,分布式系统中的每个数据库都必须在网络域中具有唯一的全局数据库名称全局数据库名称唯一标识分布式系统中的数据库服务器。

    显示了一个用户使用全局名称scott访问emp远程数据库上的表的示例hq.example.com

     数据库链接要么是私有的,要么是公共的。如果它们是私有的,那么只有创建链接的用户才能访问;如果它们是公共的,那么所有数据库用户都可以访问。

    数据库链接之间的一个主要区别是不同链接定义确定链接连接如何进行身份验证的方式。用户通过以下类型的链接访问远程数据库:

    Type of LinkDescription

    Connected user link

    Users connect as themselves, which means that they must have an account on the remote database with the same user name and password as their account on the local database.

    用户以自己的身份连接,这意味着他们必须在远程数据库上拥有与本地数据库上的帐户具有相同用户名和密码的帐户。

    Fixed user link

    Users connect using the user name and password referenced in the link. For example, if Jane uses a fixed user link that connects to the hq database with the user name and password scott/password, then she connects as scott, Jane has all the privileges in hq granted to scott directly, and all the default roles that scott has been granted in the hq database.

    用户使用链接中引用的用户名和密码进行连接。例如,如果Jane使用一个固定用户链接,该链接使用用户名和密码scott/password连接到hq数据库,那么她以scott身份连接,Jane拥有hq中直接授予scott的所有特权,以及scott在hq数据库中授予的所有默认角色。

    Current user link

    A user connects as a global user. A local user can connect as a global user in the context of a stored procedure, without storing the global user's password in a link definition. For example, Jane can access a procedure that Scott wrote, accessing Scott's account and Scott's schema on the hq database.

    用户作为全局用户连接。本地用户可以作为存储过程上下文中的全局用户进行连接,而无需在链接定义中存储全局用户的密码。例如,Jane可以访问Scott编写的过程,访问hq数据库中Scott的帐户和Scott的模式。

    使用Create database LINK语句创建数据库链接。创建链接后,可以使用它在SQL语句中指定模式对象。

    什么是共享数据库链接?

    共享数据库链接是本地服务器进程和远程数据库之间的链接。该链接是共享的,因为多个客户端进程可以同时使用同一个链接。

    当本地数据库通过数据库链接连接到远程数据库时,任何一个数据库都可以在专用或共享服务器模式下运行。

    为什么使用数据库链接?

    数据库链接的最大优点是它们允许用户访问远程数据库中另一个用户的对象,因此它们受到对象所有者的权限集的限制。换句话说,本地用户可以访问到远程数据库的链接,而不必成为远程数据库上的用户。

    例如,假设员工向应付帐款 (A/P) 提交费用报告,并进一步假设使用 A/P 应用程序的用户必须从hq数据库中检索有关员工的信息。A/P 用户应该能够连接到hq数据库并在远程数据库中执行一个存储过程hq来检索所需的信息。A/P 用户不应该是hq数据库用户才能完成他们的工作;他们应该只能以hq受程序限制的受控方式访问信息。

    数据库链接中的全局数据库名称

    要了解数据库链接的工作原理,您必须首先了解全局数据库名称是什么。分布式数据库中的每个数据库都由其全局数据库名称唯一标识。

    DB_DOMAIN数据库通过在数据库创建时由初始化参数指定的数据库网络域加上由初始化参数指定的单个数据库名称来形成全局数据库名称DB_NAME

    网络数据库的层次排列

    数据库的名称是从树的叶开始,然后沿着根路径形成的。例如,mfg数据库位于com域的example_tools分支的division3中。mfg的全局数据库名称是通过连接树中的节点来创建的,如下所示:

    • mfg.division3.example_tools.com

    虽然多个数据库可以共享单个名称,但每个数据库必须具有唯一的全局数据库名称。例如,网络域us.americas.example_auto。com和uk.europe.example_auto。com每个都包含一个销售数据库。全球数据库命名系统将美洲部门的销售数据库与欧洲部门的销售数据区分如下:

    • sales.us.americas.example_auto.com

    • sales.uk.europe.example_auto.com

    数据库链接的名称

    通常,数据库链接的名称与其引用的远程数据库的全局数据库名称相同。

    例如,如果一个数据库的全局数据库名称是sales.us.example.com,那么该数据库链接也称为sales.us.example.com

    将初始化参数GLOBAL_NAMES设置为TRUE时,数据库将确保数据库链接的名称与远程数据库的全局数据库名称相同。例如,如果hq的全局数据库名称为hq.example。如果GLOBAL_NAMES为TRUE,则链接名称必须为hq.example.com。请注意,数据库检查存储在数据字典中的全局数据库名称的域部分,而不是初始化参数文件中的DB_domain设置

    如果将初始化参数GLOBAL_NAMES设置为FALSE,则不需要使用全局命名。然后可以根据需要命名数据库链接。例如,可以将数据库链接命名为hq.example。com作为foo。

    注意:Oracle建议您使用全局命名,因为许多有用的功能都需要全局命名。

    启用全局命名后,数据库链接对分布式数据库的用户基本上是透明的,因为数据库链接的名称与链接指向的数据库的全局名称相同。例如,以下语句在本地数据库中创建到远程数据库销售的数据库链接:

    CREATE PUBLIC DATABASE LINK sales.division3.example.com USING 'sales1';

    数据库链接的类型

     Oracle 数据库允许您创建私有公共全局数据库链接。

    这些基本链接类型根据允许访问远程数据库的用户而有所不同:

    TypeOwnerDescription

    Private

    User who created the link. View ownership data through:

    • DBA_DB_LINKS

    • ALL_DB_LINKS

    • USER_DB_LINKS

    Creates link in a specific schema of the local database. Only the owner of a private database link or PL/SQL subprograms in the schema can use this link to access database objects in the corresponding remote database.

    在本地数据库的特定架构中创建链接。只有模式中私有数据库链接或PL/SQL子程序的所有者才能使用此链接访问相应远程数据库中的数据库对象。

    Public

    User called PUBLIC. View ownership data through views shown for private database links.

    Creates a database-wide link. All users and PL/SQL subprograms in the database can use the link to access database objects in the corresponding remote database.

    创建数据库范围的链接。数据库中的所有用户和PL/SQL子程序都可以使用该链接访问相应远程数据库中的数据库对象。

    Global

    No user owns the global database link. The global database link exists in a directory service.

    Creates a network-wide link. When an Oracle network uses a directory server and the database is registered in the directory service, this information can be used as a database link. Users and PL/SQL subprograms in any database can use a global database link to access objects in the corresponding remote database. Global database links refer to the use of net service names from the directory server.

    创建网络范围的链接。当Oracle网络使用目录服务器并且数据库在目录服务中注册时,此信息可以用作数据库链接。任何数据库中的用户和PL/SQL子程序都可以使用全局数据库链接访问相应远程数据库中的对象。全局数据库链接是指使用目录服务器中的网络服务名称。

    确定要在分布式数据库中使用的数据库链接类型取决于使用系统的应用程序的特定需求。选择时请考虑以下功能:

    Type of LinkFeatures

    Private database link

    This link is more secure than a public or global link, because only the owner of the private link, or subprograms within the same schema, can use the link to access the remote database.

    此链接比公共或全局链接更安全,因为只有私有链接的所有者或同一模式中的子程序才能使用此链接访问远程数据库。

    Public database link

    When many users require an access path to a remote Oracle Database, you can create a single public database link for all users in a database.

    当许多用户需要远程Oracle数据库的访问路径时,可以为数据库中的所有用户创建一个公共数据库链接。

    Global database link

    When an Oracle network uses a directory server, an administrator can conveniently manage global database links for all databases in the system. Database link management is centralized and simple.

    There is no user data associated with a global database link definition. A global database link must operate as a connected user database link.

    当Oracle网络使用目录服务器时,管理员可以方便地管理系统中所有数据库的全局数据库链接。数据库链接管理集中且简单。

     没有与全局数据库链接定义关联的用户数据。全局数据库链接必须作为连接的用户数据库链接运行。

    创建链接时,您确定应连接到远程数据库以访问数据的用户。

    下表说明了数据库链接所涉及的用户类别之间的差异:

    User TypeDescriptionSample Link Creation Syntax

    Connected user

    A local user accessing a database link in which no fixed username and password have been specified. If SYSTEM accesses a public link in a query, then the connected user is SYSTEM, and the database connects to the SYSTEM schema in the remote database.

    访问未指定固定用户名和密码的数据库链接的本地用户。如果SYSTEM访问查询中的公共链接,则连接的用户为SYSTEM,数据库连接到远程数据库中的SYSTEM模式。

    Note: A connected user does not have to be the user who created the link, but is any user who is accessing the link.

    注意:连接的用户不一定是创建链接的用户,而是访问链接的任何用户。

    CREATE PUBLIC DATABASE LINK hq USING 'hq';

    Current user

    A global user in a CURRENT_USER database link. The global user must be authenticated by an X.509 certificate (an SSL-authenticated enterprise user) or a password (a password-authenticated enterprise user), and be a user on both databases involved in the link.

    CURRENT_user数据库链接中的全局用户。全局用户必须通过X.509证书(SSL身份验证的企业用户)或密码(密码身份验证的企事业用户)进行身份验证,并且必须是链接所涉及的两个数据库上的用户。

    See Oracle Database Enterprise User Security Administrator's Guide for information about global security

    CREATE PUBLIC DATABASE LINK hq CONNECT TO CURRENT_USER using 'hq';

    Fixed user

    A user whose username/password is part of the link definition. If a link includes a fixed user, the fixed user's username and password are used to connect to the remote database.

    其用户名/密码是链接定义一部分的用户。如果链接包含固定用户,则使用固定用户的用户名和密码连接到远程数据库。

    CREATE PUBLIC DATABASE LINK hq CONNECT TO jane IDENTIFIED BY password USING 'hq';

    注意:以下用户不能是数据库链接的目标用户:SYS和PUBLIC。

    待续。。。。。。。

  • 相关阅读:
    记录一下自己写PHP程序时走过的一些坑
    自己写了一个TCP攻击测压平台
    Centos 7x 安装 Telegram MTproxy代理【完美可用】
    "@阅后即焚"上线了!
    小白的机器学习坑3:粗大的安装CUDA
    小白的机器学习坑2:nvidia驱动的安装
    小白的机器学习坑1:ubuntu 18.04的安装
    小白的linux学习笔记9:安装nodejs和gitbook
    小白的linux笔记11:放弃gitbook,转战Sphinx
    小白的linux学习笔记10:安装nginx和第一个网页
  • 原文地址:https://www.cnblogs.com/wonchaofan/p/16747168.html
Copyright © 2020-2023  润新知