CREATE DATABASE LINK

Source: Internet
Author: User

Defining a public Database link:example

The following statement defines a shared public database link named remote this refers to the database specified by the SE Rvice Name Remote:

CREATE public DATABASE LINK remote USING ' remote ';

This database link allows user hr on the local database to update a table on the remote database (assuming HR have APPROPRI Ate privileges):

UPDATE [email protected] SET salary=salary*1.1 WHERE last_name = ' Baer ';

Defining a Fixed-user database Link:example in the following statement, User HR on the remote database defines a fixed-us Er database link named local to the HR schema on the local database:

CREATE DATABASE LINK Local CONNECT to HR identified by password USING ' local ';

After this database link was created, HR can query tables in the schema HR on the local database in this manner:

SELECT * from [email protected];

User HR can also use DML statements to modify data on the local database:

INSERT into [email protected] (employee_id, last_name, email, hire_date, job_id) VALUES (999, ' Claus ', ' [email protected]', sysdate, ' Sh_clerk ');

UPDATE [email protected] SET min_salary = WHERE job_id = ' Sh_clerk ';

DELETE from [email protected] WHERE employee_id = 999;

You can create a synonym to hide the fact, a particular table is on the remote database. The following statement causes all references to emp_table to access the Employees table owned by HR on the remote Database

CREATE synonym emp_table for oe.employees @remote. us.example.com ;

CREATE DATABASE LINK

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.