1. Create a previous job
Before creating a dblink, first check whether the user has the appropriate permissions. For a specific user, after logging in using sqlplus user/pwd, execute the following statement:
Under the sys user, the displayed result is:
SYS CREATE DATABASE LINK NO
SYS DROP PUBLIC DATABASE LINK NO
SYS CREATE PUBLIC DATABASE LINK NO
It can be seen that dblink has three permissions in the database:
CREATE DATABASE LINK--The created dblink can only be used by the creator, other users cannot use
CREATE PUBLIC DATABASE LINK--public means that all users of the created dblink can use
DROP PUBLIC DATABASE LINK--Delete the specified dblink
If you want to change the permissions of a user, you need to modify it under the sys user:
There are two ways to view dblink, as follows:
①.
②.
2. Create dblink
1
2
3
4
5
6
|
create
public
database
link LINK_NAME
connect
to
USRNAME identified
by
"PASSWORD"
using
'(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = XXX.XXX.XXX.XXX)(PORT = 1521))
(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = XXX))
)'
;
|
Note: using is followed by a string, in which there must be no unnecessary spaces, otherwise an error ORA-12514 will occur . In the above code, for the convenience of reading, a line break may appear, which may cause errors, so use It's ok to remove the spaces.
Here LINK_NAM is a custom name; USERNAME and PASSWORD are the user name and password in the specified oracle database, SERVICE_NAME can be obtained by the following statement if you are not sure:
or
3. Use of dblink
The use of dblink is relatively simple. Change the table name when accessing a local table to the following format: [user.]table@link_name.
4. Delete dblink
After determining the name of the dblink to be deleted, you can delete it directly through the drop command:
I hope that this article will be helpful to everyone in Oracle database programming.