In Oracle, DBlink is used to associate tables with different databases ). There are two ways to create DBlink: creating through SQL statements and using the visualization Interface
In Oracle, database links are used to associate tables with different databases ). There are two ways to create a DB link: SQL statement creation and Visualization
In some cases, you need to associate different databases for Data Query and operations.
In Oracle, database links are used to associate tables with different databases ).
There are two ways to create a DB link: Creating an SQL statement and creating it on a visual interface (actually an executed SQL statement ).
1. Create a project using PL/SQL Developer
Name: The Name of this DBLINK. For example, DEMO
UserName: User Name for database Login
Password: Database Login Password
Database :( DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.1) (PORT = 1521) (CONNECT_DATA = (SERVICE_NAME = DEMO )))
The above red font content can be queried from the following places: \ product \ 10.2.0 \ client_1 \ network \ admin \ tnsnames. ora
DEMO =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.1) (PORT = 1521 ))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = DEMO)
)
)
Remove the above "DEMO =" and remove the linefeeds and spaces from the rest to form a string.
Click "Apply.
After it is created, it will be displayed under the Database links menu.
Test whether the DB link is valid. Execute the statement: Select * from student @ DEMO.
Student indicates the table name of the remote database.
2. Create an SQL statement
Create public databaselink V_SERVICE_NAMEconnect to V_USERNAMEidentified by V_PASSWORD using '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.1) (PORT = 1521 ))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = V_SERVICE_NAME )))';
Where:
V_SERVICE_NAME indicates the service name. You can use the SQL statement to query: SELECT * FROM GLOBAL_NAME; -- view the service name.
V_USERNAME indicates the account used to log on to the remote database.
V_PASSWORD indicates the password used to log on to the remote database.
PS: In my test, the DB link is invalid when the tns string contains a line break. If the DB link name is not a service name, the DB link is invalid.