Oracle db_link Summary

Source: Internet
Author: User

    Dblink Overview

    A database link is a schema object in one database that enables you to access objects on another database. The other database need not be an Oracle database system.

    Syntax/writing

    Create [Shared] [public] database linkDblink
    [Connect
    {CURRENT_USER
    |
    UserIdentifiedPassword[Dblink_authentication]
    }
    | Dblink_authentication
    ]...
    [Using
    Connect_string];

    keyword

    • public. If the default db_link created by default is omitted, it cannot be shared by other users and can only be used by itself.
    • shared. This keyword indicates global sharing of the created db_link (related to the session). To use this keyword, db_link_authentication is required (see example 2).
    • connect to, specifying the connection tag to connect to the remote database
    • CURRENT_USER: use the information of the current user to establish a remote database. This must ensure that the current user exists and is valid in the remote database.
    • using: Specify the address of the remote database (example)

    Example 1
    Create database link db_link_name

    Connect to remote_user_code identified by user_password

    Using '1970. 168.0.8: 192/Sid ';

    Example 2

    Create shared database_link db_link_name

    Connect to remote_user_code_1 identified by user_password_1

    Authenticated by remote_user_code_2 identified by user_password_2

    Using '1970. 168.0.8: 192/Sid'

    Example 2_1

    Create shared database_link db_link_name

    Authenticated by remote_user_code_2 identified by user_password_2

    Using '1970. 168.0.8: 192/Sid'

    Note,In Example 2, two remote_user_codes are remote_user_code_1 \ remote_user_code_2. Because the shared keyword must have authentication, connect to can be omitted (Example 2_1).

     

    Usage

    1. Select count (*) from user_tables @ db_link_name;
    2. Update sys_user @ db_link_name set user_name = '001' where age> 50
    3. Insert into sys_user @ db_link_name (user_id, user_name, age) values (001, '001', 51)
    4. Delete from user_tables @ where user_id = '001'

     

    References

      • Oracle documentation Library
      • Http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_5005.htm#SQLRF01205

 

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.