oracle 为什么我不能在 SYS 拥有的对象上创建触发器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15377346/
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
Why cannot I create triggers on objects owned by SYS?
提问by Suhail Gupta
While trying to create a trigger named ghazal_current_bef_upd_row
:
在尝试创建名为 的触发器时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;
I get the following error :
我收到以下错误:
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.
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
.
命名ghazals_current
和ghazal_current_audit
创建的表都由SYS
. 为什么我不能在由SYS
.
回答by APC
You should not be creating anyobjects 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 架构中创建任何对象。该用户是 Oracle 数据库管理系统的一部分,更改其架构可能会破坏您的数据库。当然,它可能会使您的 Oracle 支持合同无效(如果您有)。从文档:
"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."
“管理账户SYS是在创建数据库时自动创建的。这个账户可以执行所有数据库管理功能。SYS模式存储数据字典的基表和视图。这些基表和视图对Oracle数据库的操作至关重要. SYS 模式中的表仅由数据库操作,任何用户不得修改。”
Oh, in case you're wondering, the same applies to SYSTEM too.
哦,如果您想知道,这同样适用于 SYSTEM。
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.
触发器特别容易被滥用,并且是扩展问题的主要来源。这就是 Oracle 禁止我们在 SYS 中构建触发器的原因,因为这样做可能会损坏或至少影响数据字典的性能。
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 中构建了自己的表。好吧,放下它们。现在。使用 SYS 创建您自己的用户、GHAZAL 或任何适合的名称,并授予它所需的权限:CREATE SESSION、CREATE TABLE、CREATE TRIGGER 等等。然后以该新用户的身份连接以创建您的表和其他架构对象。