Dblink is to build a bridge between two databases. Users can connect to database A and use the dblink of database A to access the data of database B.
1. Query the dblink under the currently logged in user
select * from ALL_DB_LINKS
The query result is as follows,
owner: the owner, db_link: the name of the dblink, username: the user name for connecting to database B, host: the address information for connecting to database B.
2. Query all dblinks in the database
select * from dba_db_links
3. Delete the dblink of the current user
drop database link BIMAP;
4. Delete dblinks for all users
drop public database link 名称
5. Create a dblink under the current user
create database link link name connect to database B username identified by password
using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = database_ip)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME =servicename)
)
)';
6. Create a public dblink
create public database link link name connect to database B username identified by password
using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = database_ip)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME =servicename ) )
)
)';