How to create an oracle db Link
Known: database 1: test1; database 2: Test2
Requirement: Create a DB link from database 1 to database 2
Solution 1:
1. on the computer where database 1 is located, create the service name to database 2: orl_test2
2. Create a DB link between database 1 and database 2 on database 1 or other computers with Oracle clients. The method is as follows:
* Log on to SQL * Plus and enter "CREATE DATABASE LINK ".Link_nameConnectUserIdentifiedPassUsing'Orl _ test2';
(Link_name: DB Link name;User: Database username;Pass: Database Password;'Orl _ test2': Name of the database service that is locally connected to test1, enclosed in single quotes)
3. Delete the DB link. The method is as follows:
* Log on to SQL * Plus and enter drop public database link.Link_name
Solution 2:
Create a database link from database 1 to database 2 directly on database 1 or other computers with Oracle clients. The method is as follows:
Log on to SQL * Plus and enter CREATE DATABASE LINK.Link_nameConnectUserIdentifiedPassUsing
'(Description =
(Address_list =
(Protocol = TCP) (host =IP address of the computer where database 2 is located) (Port = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME =Test2)
)
)';
(Link_name: DB Link name;User: Database username;Pass: Database Password ;)
Delete dB Link
Log on to SQL * Plus and enter DROP DATABASE LINK.Link_name;