Easy as pie. Use this template:
create public database link <DB Link name> connect to <User account> identified by <Password> using '<Database SID>';
From Oracle's format in creating dblinks:
CREATE [ SHARED ] [ PUBLIC ] DATABASE LINK dblink
[ CONNECT TO
{ CURRENT_USER
| user IDENTIFIED BY password
[ dblink_authentication ]
}
| dblink_authentication
]
[ USING 'connect_string' ]
Or this one:
CREATE PUBLIC DATABASE LINK <INSTANCE><.WORLD> CONNECT TO <USER> IDENTIFIED BY <PASSWORD OF USER TO BE USED> USING '<CONNECT STRING usually INSTANCE>';
To verify your DB link, use:
select distinct db_link, created from dba_db_links where db_link='DB LINK NAME';
Common error when using your dblink is getting the ORA-02069 message. As per the following link:
http://www.oracle-developer.com/oracle-post/81/ORA_02069:_global_names_parameter_must_be_set_to_TRUE
ORA-02069: global_names parameter must be set to TRUE
If you get this error while trying to access a table over the database link.
This error happens when the database parameter global_names is set to TRUE.
When this is the case, the database link need to have the same name as the global name of the remote database (the one you are trying to connect to).
You can find out if global_names is on by using:
SQL> show parameter global_names
Find out the global name of the remote database. Log into the remote database and use:
SQL> select * from global_name;
GLOBAL_NAME
-------------------------------------------------------------------
> DB1.ORACLE-DEVELOPER.COM
Create the database link in the Oracle database appropriately:
SQL> create database link DB1 connect to scott identified by tiger using 'DB1'
Altering the password used by your DBLINK? Here are the steps:
1. Drop databae link:
drop public database link <DBLINK name>;
commit;
2. Recreate dblink:
use any of the commands above.
I've even tried using the TNSNAMES entry - just because, although I am not sure if this has any negative impact. I'm thinking no since using the DB name will also use this entry. One drawback I can think of is the cluttered result of your query when selecting from dba_db_links:
Example -
$tnsping factfinder
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = fact-finder.blogspot.com)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = fact-finder.blogspot.com)(PORT = 1521)) (LOAD_BALANCE = yes) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = factfinder) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 180) (DELAY = 5))))
OK (30 msec)
The command to create the DBLINK is:
create public database link factfinder connect to <user> identified by <password> using '((DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = fact-finder.blogspot.com)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = fact-finder.blogspot.com)(PORT = 1521)) (LOAD_BALANCE = yes) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = factfinder) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 180) (DELAY = 5))))';
create public database link <DB Link name> connect to <User account> identified by <Password> using '<Database SID>';
From Oracle's format in creating dblinks:
CREATE [ SHARED ] [ PUBLIC ] DATABASE LINK dblink
[ CONNECT TO
{ CURRENT_USER
| user IDENTIFIED BY password
[ dblink_authentication ]
}
| dblink_authentication
]
[ USING 'connect_string' ]
Or this one:
CREATE PUBLIC DATABASE LINK <INSTANCE><.WORLD> CONNECT TO <USER> IDENTIFIED BY <PASSWORD OF USER TO BE USED> USING '<CONNECT STRING usually INSTANCE>';
To verify your DB link, use:
select distinct db_link, created from dba_db_links where db_link='DB LINK NAME';
Common error when using your dblink is getting the ORA-02069 message. As per the following link:
http://www.oracle-developer.com/oracle-post/81/ORA_02069:_global_names_parameter_must_be_set_to_TRUE
ORA-02069: global_names parameter must be set to TRUE
If you get this error while trying to access a table over the database link.
This error happens when the database parameter global_names is set to TRUE.
When this is the case, the database link need to have the same name as the global name of the remote database (the one you are trying to connect to).
You can find out if global_names is on by using:
SQL> show parameter global_names
Find out the global name of the remote database. Log into the remote database and use:
SQL> select * from global_name;
GLOBAL_NAME
-------------------------------------------------------------------
> DB1.ORACLE-DEVELOPER.COM
Create the database link in the Oracle database appropriately:
SQL> create database link DB1 connect to scott identified by tiger using 'DB1'
Altering the password used by your DBLINK? Here are the steps:
1. Drop databae link:
drop public database link <DBLINK name>;
commit;
2. Recreate dblink:
use any of the commands above.
I've even tried using the TNSNAMES entry - just because, although I am not sure if this has any negative impact. I'm thinking no since using the DB name will also use this entry. One drawback I can think of is the cluttered result of your query when selecting from dba_db_links:
Example -
$tnsping factfinder
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = fact-finder.blogspot.com)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = fact-finder.blogspot.com)(PORT = 1521)) (LOAD_BALANCE = yes) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = factfinder) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 180) (DELAY = 5))))
OK (30 msec)
The command to create the DBLINK is:
create public database link factfinder connect to <user> identified by <password> using '((DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = fact-finder.blogspot.com)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = fact-finder.blogspot.com)(PORT = 1521)) (LOAD_BALANCE = yes) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = factfinder) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 180) (DELAY = 5))))';
No comments:
Post a Comment