Wednesday, October 19, 2016

CREATE DATABASE LINK


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.

Use CREATE DATABASE LINK statement to create a database link. A database link is a schema object in one database that enables you to access objects on another database.

Once you have created a database link, you can use it to view the tables on the other database using SQL statements, on the other database by appending @dblink to the table. You can also access remote tables using any INSERT, UPDATE, DELETE statements.

Create database link :
create public database link
 
connect to
 
identified by
 
using <'tns_service_name'>;

ex 1 : create database link msql connect to user_sqlserver identified by password using 'MSQL';

ex 2 : create public database link link_db connect to murthy identified by murthy123 using 'local';

ex 3 : create public database link
             demo_db                                         ---- db link name.
              connect to
                  murty identified by murthy123  -- remote db username/password
                  using '192.168.6.201:1521/orcl'; -- remote database ip with port number.



you can check the other schema tables by using the following command

sql> select * from murthy_demo@demo_db

No comments:

Post a Comment

Thanks for giving comments!!