问题:
使用SQL PLAN MANAGEMENT的时候运行下面的存储过程报错。
SYS@GOOD> conn scott/tiger
Connected.
SCOTT@GOOD> DECLARE
2 l_plans_loaded PLS_INTEGER;
3 BEGIN
4 l_plans_loaded := DBMS_SPM.load_plans_from_cursor_cache(
5 sql_id => '4tjq4phnjj1gs');
6 DBMS_OUTPUT.put_line('Plans Loaded: ' || l_plans_loaded);
7 END;
8 /
DECLARE
*
ERROR at line 1:
ORA-38171: Insufficient privileges for SQL management object operation
ORA-06512: at "SYS.DBMS_SPM", line 2327
ORA-06512: at line 4
原因是用户没有ADMINISTER SQL MANAGEMENT OBJECT权限,赋权给用户即可:
GRANT ADMINISTER SQL MANAGEMENT OBJECT to USER;
SYS@GOOD> GRANT ADMINISTER SQL MANAGEMENT OBJECT to scott;
Grant succeeded.