Pages

Tuesday, January 6, 2015

Database Link



Contents:- Database Link Concepts, How to Create Database Link

Create Database Link

There are two types of Database Link.

Public Database Link:    Public Database link can be access by any user in the database.

Private Database Link:   Private Database Link Can only access by that user only who created it. Even DBA cannot access private database link that is created by another user.

Example:- 

Create public Database Link on Target Database to Access objects that is located on Source database user Account.

Source Database:- TQS        Target Database:- TMC

Steps to Create Database Link

TQS (Source Database)

Create One Table in Source Database in HR Schema

Sql> create table demo(id number,name varchar2(10));

TMC (Target Database)

Create Database link in Target Database with the service named of source database.

Syntax:

Create database link remote connect to <source_database_user_name> identified by <source_database_user_pwd) using <source_database_service_name>;

SQL> Create database link remote connect to hr identified by hr using target_service_name;

or

SQL> Create database link remote connect to hr identified by hr using ‘192.168.1.101:1521/orcl’;

Now Select Source Database Table in Target Database By using Created Database Link


Sql> Select * from Demo@<database Link Name>

No comments:

Post a Comment