A new Oracle DBA can find here important information about database links and how to troubleshoot problems with database links.
Oracle performs these tasks before connecting to the remote database:
- If the database link name specified in the statement is partial, then Oracle expands the name to contain the domain of the local database as found in the global database name stored in the data dictionary. (You can see the current global database name in the
GLOBAL_NAME
data dictionary view.) - Oracle first searches for a private database link in your own schema with the same name as the database link in the statement. Then, if necessary, it searches for a public database link with the same name.
- Oracle always determines the username and password from the first matching database link (either private or public). If the first matching database link has an associated username and password, then Oracle uses it. If it does not have an associated username and password, then Oracle uses your current username and password.
- If the first matching database link has an associated database string, then Oracle uses it. Otherwise Oracle searches for the next matching (public) database link. If no matching database link is found, or if no matching link has an associated database string, then Oracle returns an error.
- Oracle uses the database string to access the remote database. After accessing the remote database, if the value of the
GLOBAL_NAMES
parameter istrue
, then Oracle verifies that the database.domain portion of the database link name matches the complete global name of the remote database. If this condition is true, then Oracle proceeds with the connection, using the username and password chosen in Step 2. If not, Oracle returns an error. - If the connection using the database string, username, and password is successful, then Oracle attempts to access the specified object on the remote database using the rules for resolving object references and referring to objects in other schemas discussed earlier in this section.
Column | Which Views? | Description |
OWNER | All except USER_* | The user who created the database link. If the link is public, then the user is listed as PUBLIC. |
DB_LINK | All | The name of the database link. |
USERNAME | All | If the link definition includes a fixed user, then this column displays the username of the fixed user. If there is no fixed user, the column is NULL. |
PASSWORD | Only USER_* | Not used. Maintained for backward compatibility only. |
HOST | All | The net service name used to connect to the remote database. |
CREATED | All | Creation time of the database link. |
View | Purpose |
DBA_DB_LINKS | Lists all database links in the database. |
ALL_DB_LINKS | Lists all database links accessible to the connected user. |
USER_DB_LINKS | Lists all database links owned by the connected user. |
|
|||||||||||||||||
|
|
|
|
||||||||||||||||
|
|
|
|
||||||||||||||||
|
|
|
|
Determining Which Link Connections Are Open
You may find it useful to determine which database link connections are currently
open in your session. Note that if you connect as SYSDBA, you cannot query a view to
determine all the links open for all sessions; you can only access the link information
in the session within which you are working.
The following views show the database link connections that are currently open in
your current session:
Column Which Views? Description
OWNER All except USER_* The user who created the database link. If the link is
public, then the user is listed as PUBLIC.
DB_LINK All The name of the database link.
USERNAME All If the link definition includes a fixed user, then this
column displays the username of the fixed user. If
there is no fixed user, the column is NULL.
PASSWORD Only USER_* Not used. Maintained for backward compatibility
only.
HOST All The net service name used to connect to the remote
database.
CREATED All Creation time of the database link.
View Purpose
V$DBLINK Lists all open database links in your session, that is, all database
links with the IN_TRANSACTION column set to YES.
GV$DBLINK Lists all open database links in your session along with their
corresponding instances. This view is useful in an Oracle Real
Application Clusters configuration.
Database links are either private or public. If they are private, then only the user who
created the link has access; if they are public, then all database users have access.
Drop the database link by using