本文介绍了如何在Oracle中代替触发器使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

create or replace trigger beforeInsert
instead of insert on Friends
for each row



begin
dbms_output.put_line('This operation is prohibited');
end beforeInsert;

我正在尝试创建一个触发器,该触发器将显示一条消息此操作被禁止",而不是插入到table中,但是会出现编译错误. Oracle IDE要求我在此之前或之后指定.怎么了?我知道instead of用于视图,但是如何禁止使用触发器将其插入到表中?

I am trying to create a trigger that would show a message 'This operation is prohibited' instead of inserting into table , but get a compilation error. Oracle IDE requires me to specify either before of after. What is wrong? I know that instead of is used for views, but how can I prohibit an insert to a table using a trigger?

推荐答案

INSTEAD OF触发器只能在视图上创建.

INSTEAD OF triggers can only be created on Views.

对于表,您可以创建BEFOREAFTER触发器.实际上,您可以根据需要在表上创建四种不同类型的触发器:

For a table, you can create BEFORE or AFTER triggers. In fact, you can create four different types of triggers on tables, depending on your requirements:

BEFORE STATEMENT
  BEFORE ROW
  AFTER ROW
AFTER STATEMENT

根据您的要求,如果要禁止插入表中,请不要使用触发器.而是从用户那里撤消INSERT特权.

As for your requirement, if you want to prohibit inserting into a table, don't use a trigger. Revoke the INSERT privilege from the user instead.

这篇关于如何在Oracle中代替触发器使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 12:14