Home > database >  DBlink without the use of reason and closing method
DBlink without the use of reason and closing method

Time:10-20

For simple derivative according to experience, faster than impdp command,
However, general enterprise to disable the dblink way,
The main reason is:
1, general development will not close the session, use not to close after the session have too much influence system
2, dblink no detailed logging, out of the question is not easy to search, general operation are ready-made synchronously or tool, so in order to save processing time, use the ready-made more reliable,
To close the dblink session, may refer to the following article,
Copy from: http://blog.itpub.net/9932141/viewspace-631509/
Based on db cc-link session connection pool in the session may cause target management system in the management, and resource consumption process,
Recently in A question about db session cc-link, established A DBLINK in A database, the other three servers use DBLINK to connect to A database, but in the application of the use of the connection pool for
Session management, when use DBLINK, appeared in A database session grow rapidly and reached its peak and lead to process resource consumption connection interruptions,

A:
Using the command
The alter sesssion close the database link;

Using the system package
DBMS_SESSION. CLOSE_DATABASE_LINK (dblink_name);


This way need to use in the application of the ORACLE documentation, this way is only for the current session, so the administrator SYS to shut down is not successful,
SQL> Conn/as sysdba
Connected.
SQL> Alter session close the database link test;
ERROR:
ORA - 02081: the database link is not open


Note that before using the way of command need to use the commit command first to submit, can appear otherwise ora - 02080 error,

- eg: close the dblink
Declare
V varchar2 (50);
CURSOR r IS
The select first_name from t1 @ test;
The begin
The open r;
Loop
The fetch r
Into v.
Exit the when r % NOTFOUND;
end loop;
The close r;
commit;
The execute immediate 'alter session close the database link test'.
end;




The second way:
SQLNET. The parameters set in the ORA file (for the establishment of the PROFILE, limiting the user resource use)
SQLNET. EXPIRE_TIME=
Note: in this way will lead to the user's session is affected, unless the DBLINK is used alone a user,


Three:
Use the SELECT query and form the command
Select the sid,
Serial#,
The username,
Osuser,
The machine,
'the alter system kill session' | | "" | | sid | | ', '| | serial# | |
"' immediate; 'session_level
The from v $session
Where the machine (in 'DB01', 'DB02', 'DB03');

Pay attention to the immediate behind each command added, does not add the keyword in the v $session STATUS column will be KILLED, but has not released,
Use three can make JOB regularly kill session, but that there is a big risk,

In a word, it is important to note that when using DBLINK session of recycling, use in your application
commit;
The alter sesssion close the database link;

CodePudding user response:

Can use dblink derivative according to impdp itself,

CodePudding user response:

In fact, everything is not absolute, the key is used,
  • Related