Oracle cross-database query (database link)

Source: Internet
Author: User

Oracle cross-database query (database link)

How to Create a database link for cross-database Oracle Query

Grant permissions to the dbuser account on the local Oracle Database

SQL> grant create database link to dbuser;

Configure the tnsnames. ora file of the Local Database Server
$ Vi $ ORACLE_HOME/network/admin/tnsnames. ora

Add the connection configuration that requires remote connection to the server, such:

ORCL_REMOTE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = oradb) (PORT = 1521 ))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)

Log on to the local database and create the database link

Execute the following query statement. ORCL_LINK is the database link name (customizable), and ORCL_REMOTE is the connection name defined in tnsnames. ora,
Dbuser is the user name and password

Create database link ORCL_LINK connect to dbuser identified by password using 'orcl _ remod ';

Query the method of creating database link 2:
1) Execute SQL statements.
Select * from user_db_links; -- User DB Link
Select * from dba_db_links; -- dba DB Link
Select * from v $ dblink; -- current DB Link

2) In PL/SQL, click database links in the browser on the left to view the database link.

Use connected database

Querying, deleting, and inserting data are the same as operating a local database, except that the table name must be written as "table name @ database link name", as shown in figure
Select * from table_name @ ORCL_LINK

Others:

Delete database link (ORCL_LINK in this example)
SQL> Drop database link ORCL_LINK;

Install Oracle 11gR2 (x64) in CentOS 6.4)

Steps for installing Oracle 11gR2 in vmwarevm

Install Oracle 11g XE R2 In Debian

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.