Quick Search:
 
 Oracle PL/SQL: Create Database Link Jump to:  
Category: >> Oracle PL/SQL >> Create Database Link  

<< lastnext >>

Snippet Name: Create Database Link

Description: A database link is a schema object in one database that enables you to access objects on another database. The other database need not be an Oracle Database system. (However, to access non-Oracle systems you must use Oracle Heterogeneous Services.)

Once you have created a database link, you can use it to refer to tables and views on the other database. In SQL statements, you can refer to a table or view on the other database by appending @dblink to the table or view name

Also see:
» Database Links: Close Database Link
» Database Link
» Create DB Link

Comment: (none)

Language: PL/SQL
Highlight Mode: PLSQL
Last Modified: March 07th, 2009

CREATE [ SHARED ] [ PUBLIC ] DATABASE LINK dblink
  [ CONNECT TO
    { CURRENT_USER
    | USER IDENTIFIED BY password
      [ dblink_authentication ]
    }
  | dblink_authentication
  ]
  [ USING 'connect_string' ] ;
 
 
conn_link =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = my_host_name)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = name_of_database)
    )
  )
 
 
 
-- Defining a Public Database Link:
-- The following statement defines a shared public database 
-- link named remote that refers to the database specified by 
-- the service name remote:
 
CREATE PUBLIC DATABASE LINK remote 
   USING 'remote'; 
 
 
-- This database link allows a user on the local database to 
-- update a table on the remote database (assuming the user  
-- has the appropriate privileges):
 
UPDATE employees@remote
   SET vacation_days=25
   WHERE last_name = 'Rogers';
 
 
Defining a Fixed-USER Database Link: 
-- In the following statement, the user 'mike' on the remote  
-- database defines a fixed-user database link named local to 
-- the schema on the local database:
 
CREATE DATABASE LINK local 
   CONNECT TO mike IDENTIFIED BY mike
   USING 'local';
 
 


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org