Oracle 数据库 link - 连接到用户名中包含特殊字符的代理

Oracle database link - connect to proxy with special characters in username

一个用户被授权通过另一个名称包含特殊字符的用户通过代理连接:

CREATE USER "A-USER" IDENTIFIED BY "a";
CREATE USER foo IDENTIFIED BY "random-trash";
ALTER USER foo GRANT CONNECT THROUGH "A-USER";

现在我正在努力为这个创建一个数据库link:

CREATE PUBLIC DATABASE LINK dbl CONNECT TO A-USER[FOO] IDENTIFIED BY "a";
-- ... but it complains about '-'

CREATE PUBLIC DATABASE LINK dbl CONNECT TO "A-USER[FOO]" IDENTIFIED BY "a";
-- ... but it treats whole "A-USER[FOO]" as a username

CREATE PUBLIC DATABASE LINK dbl CONNECT TO "A-USER"[FOO] IDENTIFIED BY "a";
-- ... but it expects IDENTIFIED right after closing quote

除了明显删除用户名中的特殊字符外,有什么符号可以用于此吗?

无论有无特殊字符,这都应该有效;这是在 11.2.0.3 中,首先没有:

CREATE USER "AUSER" IDENTIFIED BY "a";
CREATE USER bar IDENTIFIED BY "random-trash";
ALTER USER bar GRANT CONNECT THROUGH "AUSER";
GRANT CREATE SESSION TO "AUSER";
GRANT CREATE SESSION TO "BAR";

CREATE PUBLIC DATABASE LINK dbl CONNECT TO "AUSER[BAR]" IDENTIFIED BY "a" using 'MYDB';
SELECT * FROM dual@dbl;

D
-
X

还有:

CREATE USER "A-USER" IDENTIFIED BY "a";
CREATE USER foo IDENTIFIED BY "random-trash";
ALTER USER foo GRANT CONNECT THROUGH "A-USER";
GRANT CREATE SESSION TO "A-USER";
GRANT CREATE SESSION TO "FOO";

DROP PUBLIC DATABASE LINK dbl;
CREATE PUBLIC DATABASE LINK dbl CONNECT TO "A-USER[FOO]" IDENTIFIED BY "a" using 'MYDB';
SELECT * FROM dual@dbl;

D
-
X

两者均不适用于 11.2.0.4;有或没有特殊字符都会出错:

select * from dual@dbl
                   *
ERROR at line 1:
ORA-01017: invalid username/password; logon denied
ORA-02063: preceding line from DBL

如果您使用的是 11.2.0.4 或更高版本,那么您可能遇到了错误 19191702,它似乎破坏了通过数据库的代理功能 link。有关详细信息,请参阅 MOS 注释 19191702.8。这似乎是有意的新行为,而不是错误,而旧的行为 - 在这种情况下起作用 - 被描述为不正确。

可能有一个补丁可用于设置特定事件以恢复行为(并且它应该在 12.2 中可用),但作为 "an interim solution to allow existing applications, reliant on the [old] incorrect behaviour, to continue to work"。如果没有适用于您的平台和版本的补丁,或者活动没有帮助,那么您需要提出服务请求;当然,无论如何都值得养一只。