为什么不能在SYS拥有的对象上创建触发器? [英] Why cannot I create triggers on objects owned by SYS?

查看:102
本文介绍了为什么不能在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:

"管理帐户SYS是在以下情况下自动创建的: 数据库已创建.该帐户可以执行所有数据库 行政职能. SYS模式存储基本表和 数据字典的视图.这些基本表和视图是 对于Oracle数据库的运行至关重要. SYS中的表 模式仅由数据库操作,并且绝不能修改 任何用户."

"The administrative account SYS is automatically created when a database is created. This account can perform all database administrative functions. The SYS schema stores the base tables and views for the data dictionary. These base tables and views are critical for the operation of Oracle Database. Tables in the SYS schema are manipulated only by the database and must never be modified by any user."

哦,如果您想知道,这同样适用于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拥有的对象上创建触发器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆