为什么不能在SYS拥有的对象上创建触发器

为什么不能在SYS拥有的对象上创建触发器

本文介绍了为什么不能在SYS拥有的对象上创建触发器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试创建名为ghazal_current_bef_upd_row的触发器时:

While trying to create a trigger named ghazal_current_bef_upd_row :

create trigger ghazal_current_bef_upd_row
before update on ghazal_current
for each row
when (new.Rating < old.Rating)
begin

insert into ghazal_current_audit
 (GhazalName,Old_Rating,New_Rating)
 values
 (:old.GhazalName,:old.Rating,:new.Rating);
end;

我收到以下错误:

Error report:
ORA-04089: cannot create triggers on objects owned by SYS
04089. 00000 -  "cannot create triggers on objects owned by SYS"
*Cause:    An attempt was made to create a trigger on an object owned by SYS.
*Action:   Do not create triggers on objects owned by SYS.

名为ghazals_currentghazal_current_audit的表都是由SYS创建的.为什么我不能在SYS创建的表上创建触发器.

Both the tables named ghazals_current and ghazal_current_audit were created by SYS. Why cannot I create a trigger on the table created by SYS .

推荐答案

您不应在SYS模式中创建任何对象.该用户是Oracle数据库管理系统的一部分,更改其架构可能会破坏您的数据库.当然,这可能会使您的Oracle Support合同无效(如果有).来自文档:

You should not be creating any objects in the SYS schema. That user is part of the Oracle database management system, and changing its schema is likely to break your database. Certainly it could invalidate your Oracle Support contract (if you have one). From the documentation:

哦,如果您想知道,这同样适用于SYSTEM.

Oh, in case you're wondering, the same applies to SYSTEM too.

触发器特别容易受到滥用,并且是导致扩展问题的主要根源.这就是Oracle禁止我们在SYS中构建触发器的原因,因为这样做可能会破坏或至少影响数据字典的性能.

Triggers are particularly prone to abuse and are a major source of scaling problems. That's why Oracle forbids us to build triggers in SYS, because doing so might corrupt or at least impact the performance of the data dictionary.

当然,这不是这里发生的事情.您已经在SYS中构建了自己的表.好吧,放下它们.现在.使用SYS创建自己的用户GHAZAL或任何合适的名称,并为其授予所需的特权:CREATE SESSION,CREATE TABLE,CREATE TRIGGER等.然后以该新用户身份连接以创建表和其他架构对象.

Of course that's not what's happening here. You have built your own tables in SYS. Well drop them. Now. Use SYS to create your own user, GHAZAL or whatever name suits, and grant it the required privileges: CREATE SESSION, CREATE TABLE, CREATE TRIGGER, and so forth. Then connect as that new user to create your tables and other schema objects.

这篇关于为什么不能在SYS拥有的对象上创建触发器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 01:06