Oracle Database Links

What are Database Link:
=======================

A database link is one way method of accesing a remote database from other database provided the link should be existing in the dictionary of the local database.
We usually create a DB link based on the DB global database name.

eg:
==

A database link connection is one-way in the sense that a client connected to local database A can use a link stored in database A to access information in remote
database B, but users connected to database B cannot use the same link to access data in database A. If local users on database B want to access data on database A,
then they must define a link that is stored in the data dictionary of database B.

A database link connection allows local users to access data on a remote database. For this connection to occur, each database in the distributed system must have
a unique global database name in the network domain. The global database name uniquely identifies a database server in a distributed system.


Types of DB links:
================
Conencted user link - A local user accessing a database link in which no fixed username and password have been specified
Fixed user Link - A user whose username/password is part of the link definition. If a link includes a fixed user, the fixed user's username and password are used
                   to connect to the remote database.
Current user Link  -> In this case we should have same user account created in the remote database as your local database


Names for Database Link:
=======================
A DB link by default will have a naming convention of DBNAME.DOMAIN NAME and this is being maintained by parameter called GLOBAL_NAMES. If it is set to false then
we can use any name


DB LINK TYPES:
=============

Private: Creates link in a specific schema of the local database. Only the owner of a private database link or PL/SQL subprograms in the schema can use this link
          to access database objects in the corresponding remote database.

Public: Creates a database-wide link. All users and PL/SQL subprograms in the database can use the link to access database objects in the corresponding remote database.

Global: Creates a network-wide link. When an Oracle network uses a directory server, the directory server automatically create and manages global database links
       (as net service names) for every Oracle Database in the network. Users and PL/SQL subprograms in any database can use a global link to access objects in
   the corresponding remote database.




Commands:
=========
CREATE DATABASE LINK sales.us.americas.acme_auto.com USING 'sales_us'; -> connected
CREATE DATABASE LINK foo CONNECT TO CURRENT_USER USING 'am_sls'; -> current_user
CREATE DATABASE LINK sales.us.americas.acme_auto.com CONNECT TO scott IDENTIFIED BY tiger USING 'sales_us'; -> fixed user
CREATE PUBLIC DATABASE LINK sales CONNECT TO scott IDENTIFIED BY tiger USING 'rev';


Comments

Popular posts from this blog

Understanding Terraform

How to make CRS and ASM not to restart after server reboot

How to repair ASM disk header