Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Oracle PL/SQL: Create Database Link Jump to:  
Category: >> Oracle PL/SQL >> Create Database Link Bookmark and Share

<< 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';
 
 


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 302 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?