How Oracle implements cross-Library queries

Source: Internet
Author: User

Implementation results: Write a stored procedure under a user in a database, use Dblink to connect to another database in a stored procedure, take a number from a user in the database, and then insert a table in the current database.

Two. Implementation method steps:

1. Create a stored procedure

2. Create the database link in the stored procedure first

3. Creation success

4. Extracting data from another database into the current database

5. Task completion

Three. How to create Dblink:

1. Create Public database link Dblink

Connect to Totalplant identified by Totalplant

Using ' (DESCRIPTION =

(Address_list =

(ADDRESS = (PROTOCOL = TCP) (HOST = LOCALHOST) (PORT = 1521))

)

(Connect_data =

(service_name = PRD.GDC)

)

)‘;

Syntax Explanation: Create public database link Dblink name (pick yourself up)

Connect to User name identified by password

Using ' (DESCRIPTION =

(Address_list =

(address = (PROTOCOL = TCP) (host = IP address of the server on which the database is to be connected) (PORT = 1521))

)

(Connect_data =

(service_name = The Local service name of the database to be connected (that is, the SID of the database to be connected))

)

)‘;

2. If you create a private dblink

Create DATABASE link Dblink

Connect to Totalplant identified by Totalplant

Using ' (DESCRIPTION =

(Address_list =

(ADDRESS = (PROTOCOL = TCP) (HOST = LOCALHOST) (PORT = 1521))

)

(Connect_data =

(service_name = PRD.GDC)

)

)‘;

Four. The method of fetching the number from the connected database after successful connection:

1. Select * from [email protected];

Note: Simply add "@DBLINK name" after the table name.

Five. View all the Dblink methods under the current database:

1. Select * from Dba_db_links;

Six. Delete a specified Dblink method under the current database:

1. If you are creating a public dblink, you need to delete the

Drop public database link dblink;

2. If you are creating a private dblink, you need to delete the

drop database link dblink;

Description: Drop public database link Dblink name;

Seven. View the current database's global database name method:

1. Select * from Global_name;

Eight. See how the current user has permissions for Dblink:

1. Select DISTINCT PRIVILEGE as "Database Link privileges"

From Role_sys_privs

WHERE PRIVILEGE in (' Create SESSION ', ' Create DATABASE LINK ',

' CREATE public DATABASE LINK ');

Eight. References:

http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14231/ds_admin.htm#i1008271

How Oracle implements cross-Library queries

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.