Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Multi-database query by Oracle

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "Oracle how to achieve multi-database query", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Oracle how to achieve multi-database query" this article.

1. Configure the tnsnames.ora file for the local database server

$vi $ORACLE_HOME/network/admin/tnsnames.ora

Add the following line, where DBLINK is the connection name (customizable), HOST and PORT are the IP and port for database listening, and SERVICE_NAME is the SID of the database

MEDIADBLINK = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 10.0.0.1) (PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = db)

two。 Log in to the local database and create a database link

Execute the following query statement, where MEDIADB is the database link name (customizable) and MEDIADBLINK is the connection name previously defined in tnsnames.ora

Dbuser is the user name and password is the password

-- Create database link create database link MEDIADB connect to dbuser identified by password using 'MEDIADBLINK'

Note: the correctness of the username and password will not be verified here

3. Use linked databases

3.1 querying, deleting, and inserting data is the same as manipulating a local database, except that the table name needs to be written as "table name @ database link name", as shown in

Select * from table_name@MEDIADB

3.2 you can also create a synonym for this table

Create synonym aaa for table_name@MEDIADB

The following statement has the same effect as in 3.1

Select * from aaa

The statement to delete synonyms is

Drop synonym aaa; above is all the content of this article "how to implement multi-database query in Oracle". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report