Skip to Main Content
  • Questions
  • Running errors when DBMS_ADVISOR.TUNE_MVIEW is called

Breadcrumb

XMAS_TREE

The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.

Question and Answer

Chris Saxon

Thanks for the question, Charles.

Asked: August 14, 2020 - 7:20 pm UTC

Last updated: August 17, 2020 - 3:53 pm UTC

Version: 12.2.0.1.0

Viewed 1000+ times

You Asked

Hi Tom,

I ran into the following problems when trying to call DBMS_ADVISOR.TUNE_MVIEW.

At first, account sqltune_admin is created as follows.
create user sqltune_admin identified by sqltune_admin; 
grant select any dictionary to sqltune_admin;
grant create session to sqltune_admin;
grant oem_advisor to sqltune_admin; 
grant advisor to sqltune_admin; 


1. Case 1
DECLARE
  v_tname VARCHAR2(30) := 'MVIEW_DUMMY_TASK';
BEGIN
  DBMS_ADVISOR.TUNE_MVIEW(
      task_name      => v_tname
     ,mv_create_stmt => 
       'CREATE MATERIALIZED VIEW omv REFRESH WITH ROWID AS SELECT ''x'' dummy FROM dual');
END;
/


ORA-13600: error encountered in Advisor
QSM-03113: Cannot tune the MATERIALIZED VIEW statement
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.PRVT_ACCESS_ADVISOR", line 205
ORA-06512: at "SYS.PRVT_TUNE_MVIEW", line 1223
ORA-06512: at "SYS.DBMS_ADVISOR", line 828
ORA-06512: at line 4

Question: Is it supposed to have such an error if mview cannot be tuned?

2. Case 2
DECLARE
  v_tname VARCHAR2(30) := 'fed_vam_attached_mv';
BEGIN
DBMS_ADVISOR.TUNE_MVIEW(v_tname, '
create materialized view fs_fleet.fed_vam_attached_mv refresh fast on commit with primary key
as
select d.id from fs_ead_admin.ii_documentations d
');
END;
/

ORA-13600: error encountered in Advisor
QSM-03112: Invalid CREATE MATERIALIZED VIEW statement
ORA-01031: insufficient privileges
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.PRVT_ACCESS_ADVISOR", line 205
ORA-06512: at "SYS.PRVT_TUNE_MVIEW", line 461
ORA-06512: at "SYS.PRVT_TUNE_MVIEW", line 1132
ORA-06512: at "SYS.DBMS_ADVISOR", line 828
ORA-06512: at line 4

Question: What privilege(s) does sqltune_admin need in order to prevent the "insufficient privileges" error?

Thanks,
Charles

and Chris said...

Is it supposed to have such an error if mview cannot be tuned?

Well it's a named exception telling you it can't tune the MV, so... yes?

The process tests to see if you can make the MV fast refreshable. Which involves making an MV log on the tables in question. Which ain't gonna work on DUAL!

So I wouldn't read too much into this. If you have a test case using regular tables you don't understand please share (all the code create tables, sample data in insert into, etc.);

What privilege(s) does sqltune_admin need in order to prevent the "insufficient privileges" error?

Check that your user has

- create materialized view privilege
- select granted on fs_ead_admin.ii_documentations (directly, not via a role)

Again, it's hard to be sure here without a complete test case. If the above doesn't solve it, please create a complete test case (this time including create user statements) and post it here.

We're not taking comments currently, so please try again later if you want to add a comment.

More to Explore

Design

New to good database design? Check out Chris Saxon's full fundamentals class.