编写一个触发器实现阻止工龄小于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拥有的对象创建数据库。

解决方案 »

  1.   

    不能给sys下的对象创建触发器
    --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  /触发器已创建
      

  2.   

    create or replace trigger scott.vage_check
    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;
    ------这样就可以了
      

  3.   

    请问  改成 scott.vage_check 或在scott用户登陆sql/plus下 两种方法创建触发器有什么区别  
      

  4.   

    两种方式所引用的对象都是同一个,区别是:
    访问其它用户的对象,要在对象名称前加用户名(模式名)
    如以sys用户登录访问scott的表vage_check:
    select * from scott.vage_check
    使用scott登录,访问自己的对象,就直接使用对象名就行了
    不需要前面加上用户名来限定:
    select * from vage_check
      

  5.   

    如果你当前用户能有权限访问scott.vage_check 这个表就没区别
    否则就会报 表或视图不存在
      

  6.   

    应该是有给scott创建触发器的权限..
      

  7.   


    换个用户 已经很明显了 不能在sysdba的用户下建立
      

  8.   

    这位GG。   vage_cherk 是一个触发器