1. View dblink
select owner,object_name from dba_objects where object_type='DATABASE LINK';
Or
select * from dba_db_links;
2. Create a dblink
Prerequisites:
The user who created dblink has the corresponding database permissions.
Create public database link or CREATE DATABASE LINK
Available
grant create public database link,create database link to myAccount;
To authorize.
Create public database link dblinkname connect to username identified by password
Using '(description =
(Address_list =
(Address = (Protocol = TCP) (host = database_ip) (Port = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = servicename)
)
)';
If public is not added after create, the created dblink is not public and can only be used by the creator.
Supplement: How to Determine the database servicename:
1. Use in sqlplus
show parameter[s] service_names;
Both parameter and parameters can be used.
2. Use
select name,value from v$parameter where name='service_names'
3. Use dB Link
For example, if a public dblink of scott_rmthost is created on the local database (connected by Scott user of the remote host), sqlplus is used to connect to the local database and select * from Scott. EMP @ scott_rmthot: You can obtain the data in the EMP table of the Scott user in the remote database.
You can also create a synonym locally to point to Scott. EMP @ scott_rmthost. This makes the value more convenient.
4. Delete
Note: You have the create public database link or create database link permission.
drop public database link dblinkname;