dblink会经常遇到的两个问题:
1.由于GLOBAL_NAMES参数为TRUE时,DATABASE LINK的名称必须与被连接库的GLOBAL_NAME一致。
2.dblink名称会自动被加上后缀,dblink被加的域名和domain没关系,而是和global_name有关系。
对于第1个问题,设置global_name为false:
对于第2个问题,则是修改global_name为不带后缀的名称:
注意:
UPDATE GLOBAL_NAME SET GLOBAL_NAME='orcl';
一般修改名称使用alert database rename global_name to orcl;,但如果原global_name类似于"xxx.com"这样的名称,要去掉点分隔符,只能用 update,同时千万别为修改成''空,否则数据库无法启动。
Customer RecommendedHow To Create DB Link without Domain name when DB DOMAIN parameter is set (Doc ID 2737943.1)
DB link appending with domain name depends on GLOBAL_NAME parameter. Global name is combination of DB_DOMAIN and DB_NAME
SQL> show parameter db_domain
NAME TYPE VALUE
------------------------------------
db_domain string world.com
SQL> select global_name from global_name;
GLOBAL_NAME
--------------------------------------------------------------------------------
ORC181U.world.com
SQL> create public database link test connect to username identified by XXXXX using'orcl';
Database link created.
SQL> SELECT * FROM DBA_DB_LINKS;
OWNER DB_LINK USER SERVICE
---------- -------------------- --------
PUBLIC TEST.WORLD.COM username orcl select global_name from global_name;
GLOBAL_NAME
--------------------------------------------------------------------------------
ORC181U
SQL> create public database link testnew connect to username identified by XXXXXX using'orclpdb';
Database link created.
SQL> SELECT * FROM DBA_DB_LINKS;
OWNER DB_LINK USER SERVICE
---------- -------------------- -------- -
PUBLIC TESTNEW username orclpdb