Here is a test, in which the library creating the database link is XJ (WINDOWS 2003 Oracle 10g 10.2.0.1), the linked library is Dmdb (LINUX AS5 Oracle 10g 10.2.0.1 RAC)
Part I: How to create a Dblink
There are two ways to create Dblink:
1. Configure the target database information to be accessed in the local database Tnsnames.ora file
Create [public] database link TEST_LINK2
Connect to Scott identified by Tiger using ' test_link2 ';
The first test_link2 is the name of the Dblink that will be created,
The second test_link2 is the connection information for the target database Dmdb configured in the Tnsnames.ora file:
TEST_LINK2 =
(DESCRIPTION =
(Address_list =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.123) (PORT = 1521))
)
(Connect_data =
(SERVER = dedicated)
(service_name = mai)
)
)
Scott/tiger is the user name and password to log on to the remote database, and when the local database uses TEST_LINK2 's dblink to access the remote database, it uses Scott's identity to access
Part II: Dblink-related permissions
[Email protected] > select * from User_sys_privs where privilege like Upper ('%link% ');
USERNAME PRIVILEGE ADM
------------------------------ ---------------------------------------- ---
SYS CREATE DATABASE LINK NO
SYS DROP public DATABASE LINK NO
SYS CREATE public DATABASE LINK NO
Permission Explanation:
Create DATABASE LINK (the created Dblink can only be used by the creator itself, not other users)
Create public, which means that all users of the created Dblink can use the DATABASE LINK
Drop public DATABASE LINK (remove public dblink permissions)
Part III: Use of Dblink
If I were to compare the differences of the users of the two libraries, then I could do this now:
Select username from [email protected]_mai
Minus
Select username from dba_users;
This gives you a list of users in the target database that are not in the current user.
Another: If you like, you can use Triggers+dblink to achieve a simple data synchronization, but not recommended, play on the line.
Part IV: Related views of Dblink
There are several common views of dblink:
Dba_db_links, view all the Dblink in the system
V$dblink, which is used to see which dblink are open in the current database
When the Global_names parameter is set to True, the database link must have the same name as the global_name of the connected library when using Database link.
First look at the relevant configuration of Dmdb:
Sql> Show Parameter Global_names
NAME TYPE VALUE
------------------------------------ ----------- ---------
Global_names Boolean TRUE
Sql> CREATE DATABASE link TEST_LINK2 connect to test identified by test using ' D
MDB ';
The database link was created.
Sql> SELECT * from [email protected]_link2;
Select * FROM [EMAIL PROTECTED]_LINK2
*
Line 1th error:
ORA-02085: Database link test_link2 connected to Dmdb
Once again, the global_names of the XJ library is set to False, and the database link is available again.
Sql> alter system set GLOBAL_NAMES=FALSE; The
system has changed.
Sql> SELECT * from [email protected]_link2;
D
-
X
To see that the link is still available.
If you create a link to the XJ library on the Dmdb library, you can observe the same results. The
can draw a conclusion: the Global_names parameter is set to False, which affects the use of database links by the library that created the database link. That is, if the Global_names parameter of one library (instance) is set to True, the library connects to the database link for the other library, and its name must be the same as the global_name of the library being connected