As the business volume increases, the amount of data to be stored also increases. If all data is stored in a database, it will inevitably increase the performance consumption of the database. This will eventually lead to user unfriendly feelings. In view of this, we plan to store data in multiple copies to different databases, and databases can access each other. In this case, we need to create a dblink, that is, a domain-based database. Databases are accessed by @ domain name. Applications can also be accessed in this way. In this way, the data with a large volume of traffic is stored in an independent database, and the function configuration data and static data displayed directly to the customer are separately stored in a single database, so that the customer can quickly query and display the data in a friendly manner.
Suppose we have two databases: Database A and database B. We want to access the tables of database B from database A, but B cannot access the tables of database.
The procedure is as follows:
1. on the server of database A, add the following directory/home/Oracle/product/10.2.0/db_1/network/admin/tnsnames. ora:
DBLINK_NAME =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = 192.168.5.12) -- ip address of database B
(PORT = 1521)
)
(CONNECT_DATA =
(SERVICE_NAME = ora920) --- database B Instance name.
)
)
2. Run the command on the client of database,
Create database link "DBLINK_NAME"
Connect to INMS20 --- User Name of Data B
Identified by "password"--password of database B
Using 'dblink _ name'; -- domain NAME.
3. Access the data table dual of database B from database A client.
Select * from dual @ dblink_name;
If you want database B to access database A, you can reverse build dblink.