Sei sulla pagina 1di 3

select username, userhost, timestamp, owner, obj_name, action_name from

dba_audit_object where username='OPICS';

select * from dba_audit_object where username='OPICS';

select distinct (action_name) from dba_audit_object;

select all_audit_policies from dba_views;

select * from dba_audit_object where action_name in('SELECT', 'UPDATE', 'DELETE',


'INSERT')
order by action_name;

noaudit update,select, insert, delete on h2hmd_t_oper;

audit update, insert, delete on h2hmd_t_oper by access;

select * from dba_audit_trail;

select * from h2hmd_t_oper;

-- extraer utlimo registro de tabla


select * from (select * from dba_audit_object where action_name = 'update' order by
timestamp desc)
where rownum = 1;

-- crear trigger para insertar en tabla de auditoria de operaciones


create or replace trigger nombre_del_trigger
after update on nombre_de_tabla
for each row

declare
v_usuario varchar2(50);

begin

select user into v_usuario from dual;


-- o bien usas esta consulta
select * from (select * from dba_audit_object order by timestamp desc) where
rownum = 1;
-- o usas esta otra consulta
select * from (select * from dba_audit_object where action_name = 'UPDATE' order
by timestamp desc) where rownum = 1;

insert into nombre_de_tabla --h2h_t_auditoria_tra


( campo1,
campo2,
valor_antes,
valor_despues,
usuario)
values
( :new.campo1,
:new.campo2,
:old.campo_del_cambio,
:new.campo_del_cambio,
v_usuario);
end;
--ejemplo
declare
v_usuario varchar2(50);

begin

select user into v_usuario from dual;


-- o bien usas esta consulta
select * from (select * from dba_audit_object order by timestamp desc) where
rownum = 1;
-- o usas esta otra consulta
select * from (select * from dba_audit_object where action_name = 'UPDATE' order
by timestamp desc) where rownum = 1;

insert into h2h_t_auditoria_tra


(SERV_AUDITORIA_TRA, FECHA_AUDITORIA_TRA, HORA_AUDITORIA_TRA, IP_AUDITORIA_TRA,
USUARIO_OPER_AUDITORIA_TRA,
ID_OPER_AUDITORIA_TRA, DES_OPER_AUDITORIA_TRA, VAL_ANT_AUDITORIA_TRA,
VAL_NUEVO_AUDITORIA_TRA, TAB_AFEC_AUDITORIA_TRA)
values
('SERVICIO', :new.campo1, :new.campo2, :old.campo_del_cambio,
:new.campo_del_cambio, v_usuario);
end;

select to_char(sysdate,'dd "de " fmmonth " de " yyyy') "Fecha de contrato" from
dual;

select to_char(timestamp, 'HH24":"MI":"SS') "hora", trunc(sysdate) "fecha",


userhost, os_username, 3 "id oper", action_name, old:cupon, new:cupon, obj_name
from (select * from dba_audit_object order by timestamp desc) where rownum = 1;

create or replace trigger trg_upd_emisora


after update
on h2hmc_t_emisoras
for each row
declare
v_usuario varchar2(50);

begin

select user into v_usuario from dual;

insert into h2h_t_auditoria_tra (SERV_AUDITORIA_TRA, FECHA_AUDITORIA_TRA,


HORA_AUDITORIA_TRA, IP_AUDITORIA_TRA, USUARIO_OPER_AUDITORIA_TRA,
ID_OPER_AUDITORIA_TRA, DES_OPER_AUDITORIA_TRA, VAL_ANT_AUDITORIA_TRA,
VAL_NUEVO_AUDITORIA_TRA, TAB_AFEC_AUDITORIA_TRA)
select 'SERVICIO', trunc(sysdate), to_char(timestamp, 'HH24":"MI":"SS'),
userhost, os_username, 3, action_name, 'nuevo', 'anterior', obj_name
from (select * from dba_audit_object order by timestamp desc) where rownum = 1;
COMMIT;

end;

insert into h2h_t_auditoria_tra (SERV_AUDITORIA_TRA, FECHA_AUDITORIA_TRA,


HORA_AUDITORIA_TRA, IP_AUDITORIA_TRA, USUARIO_OPER_AUDITORIA_TRA,
ID_OPER_AUDITORIA_TRA, DES_OPER_AUDITORIA_TRA, VAL_ANT_AUDITORIA_TRA,
VAL_NUEVO_AUDITORIA_TRA, TAB_AFEC_AUDITORIA_TRA)
select 'SERVICIO', trunc(sysdate), to_char(timestamp, 'HH24":"MI":"SS'),
userhost, os_username, 3, action_name, 'nuevo', 'anterior', obj_name
from (select * from dba_audit_object order by timestamp desc) where rownum = 1;

select LAST_ACTIVE_TIME, USER, v$sqlarea.module,


v$session.MACHINE, STATUS, SID, SERIAL#, SERVER, terminal, program, sql_text,
logon_time , state
from v$sqlarea, v$session
where sql_text like '%H2H%'
AND v$sqlarea.SQL_ID = v$session.SQL_ID (+)
ORDER BY STATUS, MACHINE;