Oracle Database Links Version 21c |
---|
General Information | ||||||||||||||||||||||
Library Note |
|
|||||||||||||||||||||
Notes:
|
||||||||||||||||||||||
Data Dictionary Objects |
|
|||||||||||||||||||||
Related Files | $ORACLE_HOME/rdbms/admin/caths.sql | |||||||||||||||||||||
System Privileges |
|
|||||||||||||||||||||
Init.ora parameters related to Database Links | global_names (required to be TRUE for replication. If the value of the GLOBAL_NAMES initialization parameter is TRUE, then the database link must have the same name as the database to which it connects.global_names |
|||||||||||||||||||||
conn / as sysdba |
||||||||||||||||||||||
GLOBAL_NAMES | The global_name is made up of the db_name and the db_domain, and the first element (before the first "." in a global name is treated as the 'db_name' and the rest of the global_name is treated as the 'db_domain'.
The db_domain is automatically appended to any database link name. ~ Sybrand Bakker |
|||||||||||||||||||||
set linesize 121 |
||||||||||||||||||||||
Create Database Link | ||||||||||||||||||||||
Connected User Link | CREATE [SHARED] [PUBLIC] DATABASE LINK <link_name> |
|||||||||||||||||||||
-- create tnsnames entry for conn_link |
||||||||||||||||||||||
Current User Link | CREATE [PUBLIC] DATABASE LINK <link_name> |
|||||||||||||||||||||
CREATE DATABASE LINK curr_user |
||||||||||||||||||||||
Fixed User Link | CREATE [PUBLIC] DATABASE LINK <link_name> |
|||||||||||||||||||||
CREATE DATABASE LINK fixed_user |
||||||||||||||||||||||
Shared Link | CREATE SHARED DATABASE LINK <link_name> |
|||||||||||||||||||||
conn uwclass/uwclass@pdbdev |
||||||||||||||||||||||
Public Link | CREATE PUBLIC DATABASE LINK <link_name> |
|||||||||||||||||||||
conn sys@pdbdev as sysdba |
||||||||||||||||||||||
Close Database Link | ||||||||||||||||||||||
Close Link | ALTER SESSION CLOSE DATABASE LINK <link_name>; |
|||||||||||||||||||||
ALTER SESSION CLOSE DATABASE LINK curr_user; |
||||||||||||||||||||||
Alter Database Link | ||||||||||||||||||||||
Change Link Password | ALTER [SHARED | PUBLIC] DATABASE LINK <link_name> ....; |
|||||||||||||||||||||
CREATE DATABASE LINK fixed_user |
||||||||||||||||||||||
Drop Database Link | ||||||||||||||||||||||
Drop Standard Link | DROP DATABASE LINK <link_name>; |
|||||||||||||||||||||
DROP DATABASE LINK test_link; |
||||||||||||||||||||||
Drop Public Link | DROP PUBLIC DATABASE LINK <link_name>; |
|||||||||||||||||||||
DROP PUBLIC DATABASE LINK test_link; |
||||||||||||||||||||||
Database Link Security | ||||||||||||||||||||||
Fixed User Caution In earlier versions | set linesize 121 |
|||||||||||||||||||||
Querying Across Database Links | ||||||||||||||||||||||
Hint | By default Oracle selects the site, local or remote, on which to perform the operation. A specific site can be selected by the developer using the DRIVING_SITE hint. | |||||||||||||||||||||
Test Link | ALTER SESSION CLOSE DATABASE LINK remove_db; |
|||||||||||||||||||||
Remote PL/SQL | ||||||||||||||||||||||
SELECT over a db_link From Jonathan Lewis's FAQ |
Why does it seem that a SELECT over a db_link requires a commit after execution? Because it does! When Oracle performs a distributed SQL statement Oracle reserves an entry in the rollback segment area for the two-phase commit processing. This entry is held until the SQL statement is committed even if the SQL statement is a query. If the application code fails to issue a commit after the remote or distributed select statement then the rollback segment entry is not released. If the program stays connected to Oracle but goes inactive for a significant period of time (such as a daemon, wait for alert, wait for mailbox entry, etc…) then when Oracle needs to wrap around and reuse the extent, Oracle has to extend the rollback segment because the remote transaction is still holding its extent. This can result in the rollback segments extending to either their maximum extent limit or consuming all free space in the rbs tablespace even where there are no large transactions in the application. When the rollback segment tablespace is created using extendable files then the files can end up growing well beyond any reasonable size necessary to support the transaction load of the database. Developers are often unaware of the need to commit distributed queries and as a result often create distributed applications that cause, experience, or contribute to rollback segment related problems like ORA-01650 (unable to extend rollback). The requirement to commit distributed SQL exists even with automated undo management available with version 9 and newer. If the segment is busy with an uncommitted distributed transaction Oracle will either have to create a new undo segment to hold new transactions or extend an existing one. Eventually undo space could be exhausted, but prior to this it is likely that data would have to be discarded before the undo_retention period has expired. Note that per the Distributed manual that a remote SQL statement is one that references all its objects at a remote database so that the statement is sent to this site to be processed and only the result is returned to the submitting instance, while a distributed transaction is one that references objects at multiple databases. For the purposes of this FAQ there is no difference, as both need to commit after issuing any form of distributed query. |
|||||||||||||||||||||
Executing Remote Procedures | <procedure_name>@<database_link>(<parameters>); | |||||||||||||||||||||
exec testproc@remote_db(1); |
||||||||||||||||||||||
Remote PL/SQL | ||||||||||||||||||||||
Managing remote dependencies for functions, packages, procedures, and types |
REMOTE_DEPENDENCIES_MODE parameter is not specified, either in the init.ora parameter file or using ALTER SESSION or ALTER SYSTEM DDL statements, then timestamp is the default value.
Therefore, unless you explicitly use the REMOTE_DEPENDENCIES_MODE parameter, or the appropriate DDL statement, your server is operating using the timestamp dependency model.When using REMOTE_DEPENDENCIES_MODE=SIGNATURE:
When REMOTE_DEPENDENCIES_MODE = TIMESTAMP (the default value), dependencies among program units are handled by comparing timestamps at runtime.
If the timestamp of a called remote procedure does not match the timestamp of the called procedure, then the calling (dependent) unit is invalidated and must be recompiled.
In this case, if there is no local PL/SQL compiler, then the calling application cannot proceed.In the timestamp dependency mode, signatures are not compared. If there is a local PL/SQL compiler, then recompilation happens automatically when the calling procedure is run. When REMOTE_DEPENDENCIES_MODE = SIGNATURE , the recorded timestamp in the calling unit is first compared to the current timestamp in the called remote unit.
If they match, then the call proceeds. If the timestamps do not match, then the signature of the called remote subprogram, as recorded in the calling subprogram, is compared with the current signature of the called subprogram.
If they do not match (using the criteria described in the section "When Does a Signature Change?"), then an error is returned to the calling session.Suggestions for Managing Dependencies Follow these guidelines for setting the REMOTE_DEPENDENCIES_MODE parameter:
|
|||||||||||||||||||||
conn sys@pdbdev as sysdba |
||||||||||||||||||||||
Monitor Link Performance | ||||||||||||||||||||||
Gathering Database Link Metrics | col value format 9999999999.99 |
|||||||||||||||||||||
DB Link Related Queries | ||||||||||||||||||||||
Identify SQL Originating at Remote Databases Across DB Links | SELECT user_id, program, COUNT(DISTINCT inst_id||session_id||session_serial#) CNXN_CNT |
Related Topics |
DBMS_DBLINKS Built In Package Dropped |
DBMS_DISTRIBUTED_TRUST_ADMIN |
DBMS_SESSION.CLOSE_DATABASE_LINK |
Hints |
What's New In 21c |
What's New In 23c |
This site is maintained by Dan Morgan. Last Updated: | This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2023 Daniel A. Morgan All Rights Reserved | |||||||||
|
||||||||||