Wednesday, September 5, 2012

Oracle : Database link

For example


(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))
(CONNECT_DATA=(SID=mydb)))


1. Connect your oracle.
     > sqlplus /nolog
     > conn user/pass@mydb


2. Create db link :
     > Create database link monitordblink
connect to monitor identified by monitor123
using 'mydb';

the syntax is :

CREATE {PUBLIC} DATABASE LINK <database link name>
{CONNECT TO <oracle user id>
IDENTIFIED BY <remote oracle user's password> }
USING ' <dbstring> ';

3.  > Commit;

4. Check your db link :
    > SELECT * FROM all_db_links;


5. You can check table by using below command :
select <column list> from <table>@<dblink name>;
> select * from usertbl@monitordblink;


Source

No comments:

Post a Comment