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

前端之家收集整理的这篇文章主要介绍了oracle – 为什么我不能在SYS拥有的对象上创建触发器?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在尝试创建名为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_current和ghazal_current_audit的表都是由SYS创建的.为什么我不能在SYS创建的表上创建触发器.

您不应该在SYS模式中创建任何对象.该用户是Oracle数据库管理系统的一部分,使用它可能会破坏您的数据库.从 the documentation开始:

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

哦,万一你想知道,同样适用于SYSTEM.

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

当然,这不是这里发生的事情.您已在SYS中构建自己的表.好吧放下它们.现在.使用SYS创建您自己的用户,GHAZAL或其他任何内容并授予它所需的权限.然后以新用户身份连接以创建表和模式.

猜你在找的Oracle相关文章