oracle修改表的权限设置权限设置密码,oracle数据库设定用户修改权限

--1.禁止员工在休息日改变雇员信息

create or replace trigger tri_a

before update or insert or delete on emp

for each row

begin

if to_char(sysdate,'day') in ('Saturday','Sunday') or to_char(sysdate,'hh24:mi') not

between '08:00' and '17:00' then

raise_application_error(-20001,'非工作时间不能更改emp表');

end if;

end;

--测试

delete from emp;

--2.限制员工的工资不能超过当前的最高工资

create or replace trigger tri_a

before insert or update of sal on emp

for each row

declare

maxSal number;

pragma autonomous_transaction;--设计自制事务

begin

select max(sal) into maxSal from emp;

if :new.sal>maxSal then

raise_application_error(-20001,'工资不能大于当前最大的工资');

end if;

commit;--涉及自制事务

end;

--查询当前的最大工资

select max(sal) from emp;

--测试

insert into emp (empno,ename,sal) values(1,'dssd',7000);

update emp set sal = 7000 where empno = 7369 ;--牵扯到自制事务的问题

--3.设置员工的工资不能低于原工资,但也不能高出原工资的20%

create or replace trigger tri_a

before update of sal on emp

for each row

begin

if :new.sal<:old.sal or :new.sal>:old.sal*1.2 then

raise_application_error(-20001,'员工的工资不能低于原工资,但也不能高于原工资的20%');

end if;

end;

--测试

update emp set sal = 700 where empno= 7369;

a6fa469acd510b052ae71cc23b18495f.gif

*文章为作者独立观点,不代表上流阁立场

本文由 江风成 授权 上流阁 发表,并经上流阁编辑。转载此文章须经作者同意,并请附上出处(上流阁)及本页链接。原文链接https://www.o6c.com/java/2016/11/01/562.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值