0
点赞
收藏
分享

微信扫一扫

dbms_job调用存储过程ALTER操作报ORA-01031

unadlib 2023-04-07 阅读 67

通常情况下,DML/DDL在命令行执行时没有任何问题,在存储过程中调用时会显示ora-01031,报错的解析如下:

$ oerr ora 1031
01031, 00000, "insufficient privileges"
// *Cause: An attempt was made to change the current username or password
//         without the appropriate privilege. This error also occurs if
//         attempting to install a database without the necessary operating
//         system privileges.
//         When Trusted Oracle is configure in DBMS MAC, this error may occur
//         if the user was granted the necessary privilege at a higher label
//         than the current login.
// *Action: Ask the database administrator to perform the operation or grant
//          the required privileges.
//          For Trusted Oracle users getting this error although granted the
//          the appropriate privilege at a higher label, ask the database
//          administrator to regrant the privilege at the appropriate label.

报错的主要原因是在job方式调用存储过程中会在对应的用户下创建job相关的表,而隐式授权导致无权创建该表或无相关表的操作权限。可通过10046进行查看:

--- 打开10046
alter session set events '10046 trace name context forever, level 12';
alter session set events '1031 trace name errorstack level 1';

---执行存储过程

--- 关闭10046
alter session set events '1031 trace name errorstack off';
alter session set events '10046 trace name context off'; 

常见的解决办法:

--- DDL
grant create any table to xxx;
grant alter user to xxxx;
grant alter xxxx to xxxx;

--- DML
grant select on <user>.<object> to <the_other_user>;
grant update on <user>.<object> to <the_other_user>;
grant delete on <user>.<object> to <the_other_user>;
grant insert on <user>.<object> to <the_other_user>;
grant select/update/delete/insert on owner.tbname to other_owner;


举报

相关推荐

0 条评论