12.5. Database Links
When it comes to other Oracle database servers on the network, database links can be employed. A database link is a special database object that connects one Oracle server to another. It is created using the CREATE DATABASE LINK statement. A link can be shared, i.e., public or private. The following will create a private link:
SQL> create database link remote_db connect to scott identified by tiger using '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp) (HOST=192.168.0.120)(PORT=1521))(CONNECT_DATA= (SERVICE_NAME=orcl.ngssoftware.com)))';
Database link created. Once created, the link can then be queried using the @ sign:
SQL>SELECT USERNAME FROM ALL_USERS@REMOTE_DB
Provided the username and password are correct, the first server will connect to the second and query the ALL_USERS table.
Get The Oracle® Hacker's Handbook: Hacking and Defending Oracle now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.