Use of Oracle Dblink

Source: Internet
Author: User

Oracle has its own Dblink function, which is to logically treat multiple Oracle databases as a single database, meaning that objects in another database can be manipulated in one database, for example, we create a new data database1, We need to manipulate the tables in the database database2, or we need to manipulate the tables in the database DATABASE3 on the remote machine, and we can use this powerful feature of Dblink!

1, if we want to create a global dblink, which means that whatever role can be used, then we need to determine whether the user has Dblink permissions, if not, you need to use the SYSDBA role to authorize the user:

To see if a user has Dblink permissions:

Select *  from where  like Upper ('%database link%');

No, the SYSDBA authorization is used:

Grant Create  Public Database  to Dbusername;

2. Create a Dblink using a statement:

Create Database  to by'(DESCRIPTION = (Address_list = (ADDRESS = (      PROTOCOL = TCP) (host = connection database host IP address) (port = port number))    )    (Connect_data =      (service_name = Connection database service name)))     ';

If you create a global dblink, you must use the SYSTM or SYS user to add public before database:

Create  Public database....

For example, create Test_dblink in TESTDB2 to manipulate the TESTDB1 database in the host 192.168.1.254:

Create Database  to by'(DESCRIPTION = (Address_list = (ADDRESS = (      PROTOCOL = TCP) (HOST = 192.168.1.254) (PORT = 1521))    )    (Connect_data =      (service_name = testdb1)))    
    ';

3. Using Dblink:

Query the data in another database, other modifications, deletions are the same use, is another database table name @ This database creates the Dblink name:

Select  name @dblink from table name;

For example, we use Dblink in TESTDB2 to view data from the Tb_user table in TESTDB1:

Select *  from Tb_user@tset_dblink;

To view the Dblink created in the data:

Select owner,object_namefromwhere object_type='  DATABASE LINK'; Select *  from Dba_db_links;

Delete the corresponding Dblink:

Drop database link Dblink name;

To close the Dblink connection:

Alter Close Database ' Dblink_name '

To create and delete a view:

Create or Replace View  as (Select from user. Table name @dblink1);   Drop  view name;

After the list is created的Database links中

Use of Oracle Dblink

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.