用户被授权通过另一个名称包含特殊字符的用户通过代理进行连接:
CREATE USER "A-USER" IDENTIFIED BY "a";
CREATE USER foo IDENTIFIED BY "random-trash";
ALTER USER foo GRANT CONNECT THROUGH "A-USER";
现在我正在努力创建一个数据库链接到这个:
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,它似乎通过数据库链接破坏了代理功能。有关更多信息,请参见MOS注释19191702.8。不过,这似乎是有意的新行为,而不是一个bug,而旧的行为——这是有效的——被描述为不正确的。
可能有一个补丁可以允许设置特定事件来恢复行为(据说它在12.2中可用),但作为"一个临时解决方案,允许依赖于[旧]错误行为的现有应用程序继续工作"。如果您的平台和版本没有补丁,或者事件没有帮助,那么您需要提出服务请求;当然,养一只可能是值得的。