Sunday, 2 April 2017

Oracle Database Links

Oracle Database Link is used to establish connections between two database.
The purpose of database link is used to exchange the data between 2 databases.

Types Of Database Links: 


Public Database Link:  All users in a database can use it.

Private Database Link: Belongs to a specific database schema. Only the owner of a private database link can use it.

Global Database Link:  Defined in an OID or Oracle Names Server. Anyone on the network can use it.

Prerequisites  To Create Database Link:

  • Need to copy target database tns entry in source database tns file.
  • Need to grant CREATE DATABASE LINK to user.


Create/Drop Private DBLink:

CREATE DATABASE LINK ABC<LINK_NAME> CONNECT TO SCOTT IDENTIFIED BY TIGER USING  'ORADB<TARGET TNS>';

DROP DATABASE LINK ABC;

Create/Drop Public DBLink:

CREATE PUBLIC  DATABASE LINK ABC<LINK_NAME> CONNECT TO SCOTT IDENTIFIED BY TIGER USING  'ORADB<TARGET TNS>';

DROP PUBLIC DATABASE LINK ABC;


Close Database Link:

ALTER SESSION CLOSE DATABASE LINK ABC<LINK_NAME>;

Drop database link when you are not the owner of  the database link:

When you are the owner of the link you can drop it without any problem but if you are a DBA and want to purge the database . Lets say after restoring the TEST database from live database you can use the proxy user feature so you can connect to the database link owner  without knowing or changing it's password (Here Michel is the DBA).

SQL>CONNECTED test/test;
Connected.

TEST>CREATE DATABASE LINK mika@loop CONNECT TO TEST IDENTIFIED BY test USING 'MIKA';
Database Link Created.

TEST>CONNECT Michel/Michel;
Connected.
MICHEL>ALTER USER TEST GRANT CONNECT THROUGH MICHEL;
MICHEL>CONNECT michel[test]/michel;
Connected.
TEST>SHOW USER;
USER is "TEST".
TEST>DROP DATABASE LINK mika@loop;
Database Link Dropped.
TEST>CONNECT michel/michel;
Connected.
MICHEL>ALTER USER TEST REVOKE CONNECT THROUGH MICHEL;

User Altered.

Creating Database Link With Encrypted Password:

CREATE DATABASE LINK ABC<LINK_NAME> CONNECT TO SCOTT IDENTIFIED BY VALUES 'DEA2G0D1A57B0071057A11DA7A' USING  'ORADB<TARGET TNS>';

Views Related To Database Links:

  • DBA_DB_LINKS
  • ALL_DB_LINKS
  • USER_DB_LINKS

16 comments:

  1. Thanks for sharing this Oracle Database Links. It is really helpful, Continue sharing more like this.
    Oracle Training in Chennai | Oracle course in Chennai | Oracle DBA Training in Chennai

    ReplyDelete
  2. I simply wanted to thank you so much again. I am not sure the things that I might have gone through without the type of hints revealed by you regarding that situation.
    Best Hadoop Training Institute In chennai

    amazon-web-services-training-institute-in-chennai

    ReplyDelete
  3. This comment has been removed by a blog administrator.

    ReplyDelete
  4. You need to participate in a challenge for probably the best webpage on the web. I will enthusiastically suggest this site! online news

    ReplyDelete

  5. There's definately a ton to think about this issue. I truly like all the focuses you made.
    best interiors

    ReplyDelete
  6. Great post. keep sharing such a worthy information.
    Salesforce Training in Chennai

    ReplyDelete
  7. Infycle Technologies, the No.1 software training institute in Chennai offers the No.1 Selenium course in Chennai for tech professionals, freshers, and students at the best offers. In addition to the Selenium, other in-demand courses such as Python, Big Data, Oracle, Java, Python, Power BI, Digital Marketing, Cyber Security also will be trained with hands-on practical classes. After the completion of training, the trainees will be sent for placement interviews in the top companies. Call 7504633633 to get more info and a free demo.

    ReplyDelete
  8. This post is so interactive and informative.keep update more information...
    ccna Training in Tambaram
    ccna course in Chennai

    ReplyDelete
  9. This post is so interactive and informative.keep update more information...
    AWS Training in Velachery
    AWS Training in Chennai

    ReplyDelete
  10. Great post. keep sharing such a worthy information.
    AWS Training institute in Chennai

    ReplyDelete