使用触发器记录操作

 

    

创建表:create table student(sid int primary key,sname varchar(20))
创建日志文件:create table  log_student(logid int primary key,content varchar(20),updatedate date)
创建序列号:create sequence seq
  start with 1
  increment by 1
  minvalue 1
  maxvalue 10000000
  nocycle
  cache 20;
创建触发器:create or replace trigger tr_test
  before insert or update or delete on student 
declare
  content varchar(20);
begin
  if inserting then
    content:='新增';
  elsif updating then
     content:='修改';
  else
     content:='删除';
   end if;
   insert into log_student values(seq.nextval,content,sysdate);
end tr_test;

 


操作时间限制:create or replace trigger td_student
  before insert or update or delete on student 

declare
  content varchar(20);
begin
  if(to_char(sysdate,'DY')in('星期六','星期日'))or(to_char(sysdate,'HH24')not betwent '06' and '18')
  then
  RAISE_APPLICATION_ERROR(-20500,'非法时间修改表错误');
  end if;
end td_student;

 

 

操作时间限制:

create or replace trigger td_student
  before insert or update or delete on student 

begin
  if(to_char(sysdate,'DY')not in('星期一','星期五'))
  then
  RAISE_APPLICATION_ERROR(-20500,'休息时间,修改表错误');
  end if;
end td_student;

转载于:https://www.cnblogs.com/sunxie/archive/2010/12/09/1901028.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值