martes, 28 de febrero de 2017

Oracle Database Private Link

What is a DBLink

A database link is a one-way connection between two physical database servers that allows a client to access them as one logical database. 
For example a client connected to local database A can use a link stored in database A to access information in remote database B, but users connected to database B cannot use the same link to access data in database A. 
If local users on database B want to access data on database A, then they must define a link that is stored in the data dictionary of database B.



Privileges Necessary for Creating Database Links



To see which privileges you currently have available:

SELECT DISTINCT PRIVILEGE AS "Database Link Privileges" FROM ROLE_SYS_PRIVS
WHERE PRIVILEGE
IN ( 'CREATE SESSION','CREATE DATABASE LINK','CREATE PUBLIC DATABASE LINK')

Private Database Links Example: 


Create:

CREATE DATABASE LINK linkName
  CONNECT TO destinationDatabaseUser IDENTIFIED BY pass USING
  '(DESCRIPTION=    
   (ADDRESS=     
   (PROTOCOL=TCP)     
   (HOST=172.20.000.001)     
   (PORT=1521))    
   (CONNECT_DATA=     
   (SERVICE_NAME=Sevi_Ce)))'  ;

Use the 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. 

Drop:

DROP DATABASE LINK linkName;

You can drop a database link just as you can drop a table or view. If the link is private, then it must be in your schema. If the link is public, then you must have the DROP PUBLIC DATABASE LINK system privilege.

Close:

ALTER SESSION CLOSE DATABASE LINK linkName;

If you access a database link in a session, then the link remains open until you close the session. A link is open in the sense that a process is active on each of the remote databases accessed through the link.

Insert:

INSERT INTO RemoteDBTable@linkName SELECT * FROM LocalDBTable;


After 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. You can query a table or view on the other database with the SELECT statement. You can also access remote tables and views using any INSERT, UPDATE, DELETE, or LOCK TABLE statement.



No hay comentarios.:

Publicar un comentario