Create and test Oracle database links

Source: Internet
Author: User

Create and use Oracle DBLINK

How to create? How to use it?

Describes how to create and use Oracle database links.

A simple application scenario for Oracle DBLINK

If there are two Oracle databases, one day the business needs to make the data of one of the database tables compare and check with the data of another database table. This takes two steps:

Create DBLINK

Write related logic check SQL

Related code

  1. -- Create a public link
  2. CREATE PUBLIC DATABASE LINK TESTDBLINK
  3. Connect to remoteuser identified by REMOTEUSER_PW
  4. Using'(DESCRIPTION =
  5. (ADDRESS_LIST =
  6. (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.1) (PORT = 1521 ))
  7. )
  8. (CONNECT_DATA =
  9. (SERVICE_NAME = ORCL)
  10. )
  11. )';
  12. -- Test
  13. Select count (*) FROM PUBLIC_USER STD_L where not exists (
  14. SELECT 1 FROM PRIVATE_USER @ TESTDBLINK STD_R WHERE STD_R.USER_CODE = STD_L.USER_CODE
  15. )
  16. -- Kill Link
  17. DROP PUBLIC DATABASE LINK TESTDBLINK

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.