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.
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:
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:
The purpose of database link is used to exchange the data between 2 databases.
Types Of Database Links:
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
Thanks for sharing this Oracle Database Links. It is really helpful, Continue sharing more like this.
ReplyDeleteOracle Training in Chennai | Oracle course in Chennai | Oracle DBA Training in Chennai
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.
ReplyDeleteBest Hadoop Training Institute In chennai
amazon-web-services-training-institute-in-chennai
This comment has been removed by a blog administrator.
ReplyDeleteGreat post. keep sharing such a worthy information
ReplyDeleteTally Classes in Chennai
Tally Course in chennai
Tally training coimbatore
Tally course in madurai
Tally Course in Hyderabad
Tally Training in Chennai
Tally Course in Coimbatore
Tally Training in Hyderabad
ielts coaching centre in coimbatore
Ethical hacking course in bangalore
I am really happy with your blog because your article is very unique and powerful for new reader.
ReplyDeleteweb designing training in chennai
web designing training in omr
digital marketing training in chennai
digital marketing training in omr
rpa training in chennai
rpa training in omr
tally training in chennai
tally training in omr
.Wow, amazing weblog format! How lengthy have you been running a blog for? you make running a blog look easy. The total glance of your website is wonderful, let alone the content!.
ReplyDeletehadoop training in chennai
hadoop training in velachery
salesforce training in chennai
salesforce training in velachery
c and c plus plus course in chennai
c and c plus plus course in velachery
machine learning training in chennai
machine learning training in velachery
You need to participate in a challenge for probably the best webpage on the web. I will enthusiastically suggest this site! online news
ReplyDelete
ReplyDeleteThere's definately a ton to think about this issue. I truly like all the focuses you made.
best interiors
Great post. keep sharing such a worthy information.
ReplyDeleteSalesforce Training in Chennai
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.
ReplyDeleteAwesome blog. Thanks for sharing such a worthy information....
ReplyDeleteAngularjs Training in Bangalore
Angularjs classes in pune
This post is so interactive and informative.keep update more information...
ReplyDeleteccna Training in Tambaram
ccna course in Chennai
Nice blog! Thanks for sharing this valuable information
ReplyDeleteGreatest Challenges of Selenium
Challenges of Selenium
This post is so interactive and informative.keep update more information...
ReplyDeleteAWS Training in Velachery
AWS Training in Chennai
Amazing post.Thanks for sharing a valuable information......
ReplyDeleteDevOps Tools
Technologies used by Devops and its Tools
Great post. keep sharing such a worthy information.
ReplyDeleteAWS Training institute in Chennai