加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-12 13:09:01 所属栏目:百科 来源:网络整理
导读:在尝试创建名为ghazal_current_bef_upd_row的触发器时: create trigger ghazal_current_bef_upd_rowbefore update on ghazal_currentfor each row when (new.Rating old.Rating)begininsert into ghazal_current_audit (GhazalName,Old_Rating,New_Rating)
在尝试创建名为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
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.

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读