如何在密码中创建一个带符号(&)的数据库链接

时间:2016-04-20 10:02:49

标签: oracle oracle11g

正如标题所说。有没有办法在不更改架构密码的情况下使用&符密码创建数据库链接?

CREATE DATABASE LINK DBLINK_NAME
CONNECT TO SCHEMA_NAME IDENTIFIED BY p&ssword 
USING '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=host.name.com)(Port=1521))(CONNECT_DATA=(SID=host)))';

2 个答案:

答案 0 :(得分:1)

密码中的“&”是棘手的,因为它是定义字符,您可以通过以下方式查看:

show define;

您应该能够通过将密码括在引号中来规避这一点,然后当您被要求“输入替换变量”时,输入&符号和尾随字符,如下所示:

SQL> CREATE DATABASE LINK DBLINK_NAME
CONNECT TO SCHEMA_NAME IDENTIFIED BY "p&ssword" 
USING '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=host.name.com)(Port=1521))(CONNECT_DATA=(SID=host)))';

Enter value for ssword: &ssword

old    1:      CREATE DATABASE LINK DBLINK_NAME
    CONNECT TO SCHEMA_NAME IDENTIFIED BY "p&ssword" 
    USING '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=host.name.com)(Port=1521))(CONNECT_DATA=(SID=host)))';
new    1:     CREATE DATABASE LINK DBLINK_NAME
    CONNECT TO SCHEMA_NAME IDENTIFIED BY "p&ssword" 
    USING '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=host.name.com)(Port=1521))(CONNECT_DATA=(SID=host)))';

Database link created.

答案 1 :(得分:1)

通过使用set escape on和转义&符号来解决它

SET ESCAPE ON;
CREATE DATABASE LINK DBLINK_NAME
CONNECT TO SCHEMA_NAME IDENTIFIED BY p\&ssword 
USING '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=host.name.com)(Port=1521))(CONNECT_DATA=(SID=host)))';