编写一个触发器实现阻止工龄小于18的用户增加到数据库 emp 表中
emp(empno,ename,job,mgr,hiredate,sal,comm,deptno) 在sys as sysdba 的用户下创建的表我编的触发器
create or replace trigger vage_check
before insert on emp
for each row
begin
if add_months( :new.hiredate,18*12)>sysdate then
RAISE_APPLICATION_ERROR(-20001, 'Employees must at least eighteen years of age.');
end if;
end;出现错误:无法对sys拥有的对象创建数据库。
emp(empno,ename,job,mgr,hiredate,sal,comm,deptno) 在sys as sysdba 的用户下创建的表我编的触发器
create or replace trigger vage_check
before insert on emp
for each row
begin
if add_months( :new.hiredate,18*12)>sysdate then
RAISE_APPLICATION_ERROR(-20001, 'Employees must at least eighteen years of age.');
end if;
end;出现错误:无法对sys拥有的对象创建数据库。
解决方案 »
- 请问大家一个SQL语句里面字符串计算的问题
- wm_concat能取到合并行后值的数量吗,或者如何取字段中以逗号分割的字符的数量?
- pl/sql 存储过程
- Re:表查询问题?
- oc4j出现的问题
- 無人能解 敬妙觸發 在線送分﹗﹗﹗ 500分
- ORACLE和SQLSERVER做DBLINK
- 关于oralce函数的写法? select getStr( product_model) from table 1, 返回的是 产口的型号,如(SD1, SG2, SJ3),在线等
- Oracle的锁有几种?
- oracle存储过程,第一次写,求大神们指点。。。在线求解。。。。。
- 求助 多DB下的事物管理!!
- 关联查询sql语句
--scott下的没问题
scott@YPCOST> create or replace trigger vage_check
2 before insert on emp
3 for each row
4 begin
5 if add_months( :new.hiredate,18*12)>sysdate then
6 RAISE_APPLICATION_ERROR(-20001, 'Employees must at least eighteen years of age.');
7 end if;
8 end;
9 /触发器已创建
before insert on scott.emp
for each row
begin
if add_months( :new.hiredate,18*12)>sysdate then
RAISE_APPLICATION_ERROR(-20001, 'Employees must at least eighteen years of age.');
end if;
end;
------这样就可以了
访问其它用户的对象,要在对象名称前加用户名(模式名)
如以sys用户登录访问scott的表vage_check:
select * from scott.vage_check
使用scott登录,访问自己的对象,就直接使用对象名就行了
不需要前面加上用户名来限定:
select * from vage_check
否则就会报 表或视图不存在
换个用户 已经很明显了 不能在sysdba的用户下建立