logon觸發器for dba

zhouwf0726發表於2019-04-16

DBA管理工作中有時候需要用到logon觸發器解決很多問題:

來自yxyup。


----trace-----
create or replace trigger exp_login
after logon on database
declare
v_sid number;
v_serial number;
begin
select sid into v_sid from v$session where lower(program) like 'exp%';
select serial# into v_serial from v$session where sid=v_sid;
sys.dbms_system.set_sql_trace_in_session(v_sid,v_serial,true);
exception
when others then
dbms_output.put_line('login trigger error:' || sqlerrm);
end exp_login;
/

---export modify parameters----
create or replace trigger exp_login_mod
after logon on database
declare
v_sid number;
v_serial number;
begin
select sid,serial# into v_sid ,v_serial from v$session where lower(program) like 'exp%' ;
sys.dbms_system.set_int_param_in_session(v_sid ,v_serial,'db_file_multiblock_read_count',128);
sys.dbms_system.set_bool_param_in_session(v_sid ,v_serial,'_serial_direct_read', true);
sys.dbms_system.set_sql_trace_in_session(v_sid,v_serial,true);
exception
when others then
dbms_output.put_line('login trigger error:' || sqlerrm);
end exp_login;
/


---import modify parameters----
create or replace trigger exp_login_mod
after logon on database
declare
v_sid number;
v_serial number;
begin
select sid,serial# into v_sid ,v_serial from v$session where lower(program) like 'exp%' ;
sys.dbms_system.set_int_param_in_session(v_sid, v_serial,'db_file_multiblock_read_count', 128);
sys.dbms_system.set_int_param_in_session(v_sid, v_serial, 'sort_area_size', 104857600);
sys.dbms_system.set_int_param_in_session(v_sid, v_serial, 'sort_area_retained_size', 104857600);
sys.dbms_system.set_int_param_in_session(v_sid, v_serial, 'sort_multiblock_read_count', 128);
exception
when others then
dbms_output.put_line('login trigger error:' || sqlerrm);
end exp_login;
/

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/756652/viewspace-242481/,如需轉載,請註明出處,否則將追究法律責任。

相關文章