• oracle 触发器


    ----触发器---
    ---创建中间插入的表

    create table session_history tablespace bap_data
    as (select sid,username,program,machine,'000.000.000.000'ipadd,sysdate moditime from v$session where 0=1);

    ---创建触发器---只要登陆数据库就触发

    create or replace trigger on_logon_trigger
     after logon on database
     begin
    insert into session_history select sid,username,program,machine,sys_context('userenv','ip_address'),sysdate from v$session where audsid = userenv('sessionid');
    end;

    ---查询登陆信息
    select * from  session_history q where q.username not in ('SYS');

    -------触发器针对对数据库表做修改-------
    1.创建存触发触发器数据的表

     create table test.trigger_test tablespace test_data as (select sid,username,program,machine,'000.000.000.000'ipadd,sysdate moditime from v$session where 0=1);

     2.创建对应触发器
    create or replace trigger test.T_test_trigger
     before delete or update on test.T_test
     for each row
    begin
     insert into test.trigger_test select sid,username,program,machine,sys_context('userenv','ip_address'),sysdate from v$session where audsid = userenv('sessionid');
     end;

     3.给触发器所有者赋权限
    grant select,update,insert on bap.trigger_test to test;

    4.测试触发器是否生效
     update  BAP.T_test qq set qq.bnk_no='' where  BNK_CD='888';

    5.验证是否有数据入表
     select * from test.trigger_test;

    6.其他操作
    --DROP trigger  test.T_test_trigger
    select * from dba_triggers ww where ww.owner=TEST;

  • 相关阅读:
    CSS同时选择器
    create-react-app之proxy
    mysql limit语句
    给tbody加垂直滚动条的具体思路
    MySql数据类型范围
    block、inline、inline-block
    javascript sourcemap
    session of express
    React中innerHTML的坑
    box-sizing
  • 原文地址:https://www.cnblogs.com/ss-33/p/8930760.html
Copyright © 2020-2023  润新知