Hi,
Sometimes You can get ” ORA-20000: Insufficient privileges to Analyze an object in Schema ” error during Gather DBMS_STATS Database, Schema, Table and Dictionary Stats.
ORA-20000: Insufficient privileges
Details of error are as follows.
ORA-20000: Insufficient privileges to analyze an object in Schema ORA-06512: at "SYS.DBMS_STATS", line 13578 ORA-06512: at "SYS.DBMS_STATS", line 13937 ORA-06512: at "SYS.DBMS_STATS", line 14015 ORA-06512: at "SYS.DBMS_STATS", line 13974 ORA-06512: at line 1
ORA-20000: Insufficient privileges to Analyze an object in Schema
When you start the gather stats job without sys user ( sysdba priviliges ), you can get this error.
To solve this error, you should grant ANALYZE ANY DICTIONARY,ANALYZE ANY priviliged to the the related user as follows.
grant ANALYZE ANY DICTIONARY to MSDBA; grant ANALYZE ANY to MSDBA; Grant SELECT ANY TABLE to MSDBA;
Gather DBMS_STATS
You can gather fixed object stats as follows.
BEGIN DBMS_STATS.GATHER_FIXED_OBJECTS_STATS; END; /
You can gather dictionary stats as follows.
BEGIN DBMS_STATS.gather_dictionary_stats; END; /
You can gather any schema stats as follows.
BEGIN DBMS_STATS.gather_schema_stats('MSDBA',estimate_percent => dbms_stats.auto_sample_size, degree=>96); END; /
You can gather any table stats as follows.
BEGIN DBMS_STATS.gather_table_stats(ownname='MSDBA',tabname='TEST_TABLE', estimate_percent=> dbms_stats.auto_sample_size, degree=>8 ); END; /
Do you want to learn more details about Database Stats , Schema Stats & Dictionary and Fixed Object Statistics, then read the following post.
Do you want to learn more details about RMAN, then read the following articles.
RMAN Tutorial | Backup, Restore and Recovery Tutorials For Beginner Oracle DBA