Wednesday, July 23, 2014

DB_LINKS in oracle

DB_LINKS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A database link (DBlink) is a definition of how to establish a connection from one Oracle database to another.

The following link types are supported:

    Private database link - belongs to a specific schema of a database. Only the owner of a private database link can use it.
    Public database link - all users in the database can use it.
    Global database link - defined in an OID or Oracle Names Server. Anyone on the network can use it. 



SYNTAX
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CREATE [PUBLIC/SHARED] DATABASE LINK <link_name> CONNECT TO <user_name> IDENTIFIED BY <password> USING '<service_name>';


create database link mylink connect to remote_username identified by  mypassword using 'tns_service_name';

create public database link mylink connect to remote_username identified by  mypassword using 'tns_service_name';

create shared database link mylink connect to remote_username identified by  mypassword using 'tns_service_name';

create database link testlink_db2 connect to system identified by oracle 
using
 '(DESCRIPTION=
    (ADDRESS=
     (PROTOCOL=TCP)
     (HOST=10.2.10.18)
     (PORT=1525))
   (CONNECT_DATA=
   (SID=test10)))'
/


DROP DB_LINK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DROP DATABASE LINK <DB_LINK_NAME>;


CLOSE DB_LINK SESSION
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ALTER SESSION CLOSE DATABASE LINK <link_name>;



DB_links views
~~~~~~~~~~~~~~~~~~~~~~~~~
all_db_links
dba_db_links
user_db_links
dbms_dblink
dbms_dblink_lib
wmp_db_links_v
ora_kglr7_db_links
gv_$session_connect_info
repcat$_repprop_dblink_how
ku$_dblink_t
ku$_dblink_view
wmp_api_dblink
ku$_10_1_dblink_view
gv_$dblink




No comments:

Post a Comment