• Imprimir

 

cd /u01/app/oracle/product/11.2.0.4/db_1/network/admin --> sendo $ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1

 

$ vi tnsnames.ora

 

<< NOME DO BANCO REMOTO >> =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = <<IP DO BANCO REMOTO>>)(PORT = 1521)) # Sendo PORT padrao 1521

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = << NOME DO BANCO REMOTO >>)

    )

  )

 

# Vamos no sqlplus 

$ sqlplus sys as sysdba

 

# Listando db_link

SELECT owner,db_link,username,host FROM dba_db_links ORDER BY owner, db_link

 

# Criando o db_link 

CREATE DATABASE LINK << NOME DO LINK >> CONNECT TO <<usuario remoto>> IDENTIFIED BY "<<senha usuario remoto>>"  using '<< NOME DO BANCO REMOTO >>';

 

# Listando db_link

SELECT owner,db_link,username,host FROM dba_db_links ORDER BY owner, db_link;

 

# Deletando o db_link

DROP DATABASE LINK << NOME DO LINK >>; 

 

 

# Listando db_link

SELECT owner,db_link,username,host FROM dba_db_links ORDER BY owner, db_link;

 

# Criando o db_link PUBLIC

CREATE PUBLIC DATABASE LINK << NOME DO LINK >> CONNECT TO <<usuario remoto>> IDENTIFIED BY "<<senha usuario remoto>>"  using '<< NOME DO BANCO REMOTO >>';

 

# Testando

select * from <<TABELA BANCO REMOTO>>@<< NOME DO LINK >>;

 

# Deletando o db_link PUBLIC

DROP PUBLIC DATABASE LINK << NOME DO LINK >>;

 

 

Outras consultas :

 

select * from DBA_DB_LINKS;

select * from ALL_DB_LINKS;