无法在 Oracle 中使用 SQLPlus 创建触发器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/994242/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't create trigger using SQLPlus in Oracle
提问by udit
I'm Learning Oracle and wanted to try creating a trigger. I tried this example form a book in sqlplus.
我正在学习 Oracle 并想尝试创建一个触发器。我在 sqlplus 中尝试了这个例子形成一本书。
SQL> CREATE OR REPLACE TRIGGER policy_bull BEFORE insert or update
2 ON emp
3 FOR EACH ROW
4 BEGIN
5 :new.salary := 200;
6 END
7 /
ERROR at line 1: ORA-04089: cannot create triggers on objects owned by SYS
第 1 行的错误:ORA-04089:无法在 SYS 拥有的对象上创建触发器
even though I logged in as SYS using
即使我使用 SYS 登录
sqlplus "sys/oracle as sysdba"
sqlplus "sys/oracle 作为 sysdba"
回答by Jeffrey Kemp
You need to type / on a blank line to tell SQLPLUS to run the statement.
您需要在空行中键入 / 以告诉 SQLPLUS 运行该语句。
回答by UncleO
Oracle forbids creating triggers on objects owned by SYS.
Oracle 禁止在 SYS 拥有的对象上创建触发器。
Did you create the table emp as SYS? You probably want to be a regular user to do that. emp doesn't sound like a system table.
您是否将表 emp 创建为 SYS?您可能希望成为普通用户来做到这一点。emp 听起来不像系统表。
回答by udit
I think a semi-colon is missing after END. Also mention SYS.emp
我认为 END 之后缺少分号。还要提到SYS.emp
回答by Venk
SQL> CREATE OR REPLACE TRIGGER policy_bull BEFORE insert or update 2 of SALARY on EMP 3 FOR EACH ROW 4 BEGIN 5 :new.salary := 200; 6 END 7 /
SQL> CREATE OR REPLACE TRIGGER policy_bull BEFORE insert or update 2 of SALARY on EMP 3 FOR EACH ROW 4 BEGIN 5 :new.salary := 200; 6 完 7 /
you have to type the column where the "NEW SALARY" is ppl its SALARY so ...or update of SALARY on EMP...
你必须输入“新工资”是它的工资的列,所以……或者在 EMP 上更新工资……