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

查看:49
本文介绍了为什么我不能在 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 支持合同无效(如果您有).来自文档:

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天全站免登陆