简体   繁体   English

Oracle公共共享数据库链接不适用于非DBA用户

[英]Oracle public shared database link not working for non-DBA users

I need to convert a database link that I have in Oracle from a normal public database link to a public shared database link. 我需要将Oracle中的数据库链接从普通的公共数据库链接转换为公共共享数据库链接。

I ran the following as my user with DBA privileges to make the link shared: 我以具有DBA特权的用户身份运行以下命令,以使链接共享:

DROP PUBLIC DATABASE LINK "MYDBLINK";

CREATE SHARED PUBLIC DATABASE LINK "MYDBLINK"
AUTHENTICATED BY SOME_USER
IDENTIFIED BY thepassword
USING 'OTHERDB';

I used the same username and password as the database link was already using. 我使用的用户名和密码与数据库链接已使用的用户名和密码相同。

When I query across the database link with my user that has DBA privileges, it works fine. 当我用具有DBA特权的用户查询数据库链接时,它可以正常工作。 But when I use a non-DBA privileged user, and I inspect the database link, it shows that the user name for the database link is null , and if I try to query across the link, I get: 但是,当我使用非DBA特权用户并检查数据库链接时,它表明数据库链接的用户名为null ,并且如果我尝试查询链接,则会得到:

ORA-01017: invalid username/password; ORA-01017:无效的用户名/密码; logon denied 登录被拒绝

Any ideas why the link would behave differently for non-DBA users? 对于非DBA用户,为什么链接会有不同的行为?

Authentication to the remote database is done by using the credential defined on AUTHENTICATED BY clause. 通过使用在AUTHENTICATED BY子句中定义的凭据,可以完成对远程数据库的身份AUTHENTICATED BY Once the connection is established, operation on the remote database proceeds with the privileges of the user defined on CONNECT TO clause or CURRENT USER , no the AUTHENTICATED BY schema. 建立连接后,将使用在CONNECT TO子句或CURRENT USER上定义的用户特权(而不是AUTHENTICATED BY模式)对远程数据库进行操作。

In your case, you have not defined CONNECT TO schema hence it is using the current user in the local database to operate on the remote database. 在您的情况下,您尚未定义CONNECT TO模式,因此它使用本地数据库中的当前用户对远程数据库进行操作。 If your currently logged in user on the local database doesn't exist on the remote server then you get this error. 如果远程服务器上不存在您当前在本地数据库上登录的用户,则会出现此错误。

Here is a demo . 这是一个演示

On a Local Database( AS SYSDBA ) 在本地数据库上( AS SYSDBA

SQL> CREATE SHARED PUBLIC DATABASE LINK link2remotedb
AUTHENTICATED BY userA_uat IDENTIFIED BY userA_uat
USING 'ORCLUAT';  

Database link created.

Then I connected by a user which exists on my local database but not on the remote database. 然后,我由一个存在于本地数据库但不存在于远程数据库上的用户连接。

SQL> conn jay/jay
Connected.
SQL> select * from address@link2remotedb;
select * from address@link2remotedb
                      *
ERROR at line 1:
ORA-01017: invalid username/password; logon denied
ORA-02063: preceding line from LINK2REMOTEDB

The error has occurred because the SELECT operation used the current user which is JAY to select from the ADDRESS table on the remote database. 发生错误是因为SELECT操作使用当前用户JAY从远程数据库的ADDRESS表中进行选择。 JAY user doesn't exist on the remote database. JAY用户在远程数据库上不存在。

So, what next? 那么,接下来呢?

Define the user in CONNECT TO clause. CONNECT TO子句中定义用户。

SQL> CREATE SHARED PUBLIC DATABASE LINK link2remotedb
CONNECT TO userA_uat IDENTIFIED BY userA_uat
AUTHENTICATED BY userA_uat IDENTIFIED BY userA_uat
USING 'ORCLUAT'; 

Database link created.

SQL> conn jay/jay
Connected.
SQL> select * from address@link2remotedb;

Documentation 文档

  • Using Shared Database Links 使用共享数据库链接

  • 声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

    相关问题 以用户身份连接时,在Oracle数据库中收集dba_users信息 - gather dba_users information in Oracle database when connected as a user 以普通用户身份连接时在不授予特权的情况下在Oracle数据库中收集dba_users信息 - gather dba_users information in Oracle database when connected as normal user without granting privileges 尝试在Oracle DB中标识架构列表时dba_segments和dba_users之间的区别 - Difference between dba_segments and dba_users when trying to identify list of schema in Oracle DB 如何通过公用数据库链接将数据从一个表插入到两个Oracle数据库服务器的另一个表中? - How to insert data from one table to another from two oracle database servers with public database link? 适用于Oracle Developer / DBA的SQL Server - SQL server for an oracle developer/dba 如何在Oracle数据库的DBA_SYS_PRIVS表中标识用户帐户 - How to identify user account in DBA_SYS_PRIVS table in Oracle Database 同步数据库中的Oracle数据库用户 - Oracle Database Users in synced database Oracle 创建数据库链接 - Oracle creating Database link 适用于Android用户的公共SQLite数据库 - Public SQLite Database for android users 列式数据库比较和DBA工作 - Columnar Database Comparisons and DBA efforts
     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM