怎样在某一个时间点,用触发器禁止修改SQL数据库中某一个表中的数据。SQL语句怎么写?

怎样在某一个时间点,用触发器禁止修改SQL数据库中某一个表中的数据。SQL语句怎么写?,第1张

create or replace trigger aaa_t

before update or insert or delete on aaa

for each row

declare

-- local variables here

begin

if to_char(sysdate,'yyyy-mm-dd')='2013-03-10' then

Raise_Application_Error(-20001, '不能修改')

end if

end aaa_t

需要用update语句

如test表中有如下数据

要将begintime改成当前日期时间,可用如下语句:

12update test set begintime=sysdatecommit

更新后结果:

修改月份:

update attendpunch set punchtime= convert(nvarchar,year(punchtime))+'-'+'要修改的月份' + right(convert(nvarchar(19),punchtime,120),12) where 条件

修改天数的稍微变通下就行了。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9420131.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-28
下一篇2023-04-28

发表评论

登录后才能评论

评论列表(0条)

    保存