Home » RDBMS Server » Server Administration » DBMS_STATS.GATHER_SCHEMA_STATS
DBMS_STATS.GATHER_SCHEMA_STATS [message #120067] Tue, 17 May 2005 10:42 Go to next message
kapil2005
Messages: 44
Registered: March 2005
Member
I am getting following error message when i run a procedure and all it does is run DBMS_STATS.gather_schema_stats(ownname =>'SOMEUSER', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE, cascade => TRUE);

BEGIN SYSTEM.ANAL_SCHEMAS; END;

*
ERROR at line 1:
ORA-20000: Insufficient privileges to analyze an object in Schema
ORA-06512: at "SYS.DBMS_STATS", line 10156
ORA-06512: at "SYS.DBMS_STATS", line 10324
ORA-06512: at "SYS.DBMS_STATS", line 10378
ORA-06512: at "SYS.DBMS_STATS", line 10355
ORA-06512: at "SYSTEM.ANAL_SCHEMAS", line 22
ORA-06512: at line 1

When i run the "DBMS_STATS.gather_schema_stats(ownname =>'SOMEUSER', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE, cascade => TRUE);" manually from sqlplus it executes successfully with any problems.
anyone has any idea? i was wondering, if the pinned tables would cause this? i have some tables pinned and packages kept in shared_pool. and these objects are owned by someuser and system runs this procedure.

Thank you,
Kapil
Re: DBMS_STATS.GATHER_SCHEMA_STATS [message #120091 is a reply to message #120067] Tue, 17 May 2005 14:27 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
procedure SYSTEM.ANAL_SCHEMA is in System schema.
Pl/sql will not see the privs given through roles.
grant a direct execute priv on ANAL_SCHEMA to executing user.
And having any NON SYSTEM object in SYSTEM schema is bad.
Re: DBMS_STATS.GATHER_SCHEMA_STATS [message #120095 is a reply to message #120067] Tue, 17 May 2005 14:46 Go to previous messageGo to next message
kapil2005
Messages: 44
Registered: March 2005
Member
User System is gathering statistics of someuser(objects) through a stored procedure, there are no non-system objects in system schema. and some of these objects(Tables) owned by someuser are pinned. so i was wondering if that causes any problem

[Updated on: Tue, 17 May 2005 14:48]

Report message to a moderator

Re: DBMS_STATS.GATHER_SCHEMA_STATS [message #120101 is a reply to message #120095] Tue, 17 May 2005 15:23 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
>> these objects(Tables) owned by someuser are pinned

No. Not relevant at all.

SYSTEM is not a superuser.
Still having custom objects like user created stored procs in SYSTEM schema is not good.

system@9i > create or replace procedure anal_schema
  2  as
  3  begin
  4  DBMS_STATS.gather_schema_stats(ownname =>'SCOTT', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE, cascade => TRUE);
  5  end;
  6  /

Procedure created.

system@9i > exec system.anal_schema;
BEGIN system.anal_schema; END;

*
ERROR at line 1:
ORA-20000: Insufficient privileges to analyze an object in Schema
ORA-06512: at "SYS.DBMS_STATS", line 9876
ORA-06512: at "SYS.DBMS_STATS", line 10041
ORA-06512: at "SYS.DBMS_STATS", line 10095
ORA-06512: at "SYS.DBMS_STATS", line 10072
ORA-06512: at "SYSTEM.ANAL_SCHEMA", line 4
ORA-06512: at line 1


system@9i > !sqlplus -s "sys/sys as sysdba"
grant analyze any to system;

Grant succeeded.

exit

system@9i > exec anal_schema;

PL/SQL procedure successfully completed.

system@9i > exec system.anal_schema;

PL/SQL procedure successfully completed.
Re: DBMS_STATS.GATHER_SCHEMA_STATS [message #120104 is a reply to message #120101] Tue, 17 May 2005 15:34 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
and in 9i, gather_schema_stats has some known issues.
So be cautioned by using it.
Re: DBMS_STATS.GATHER_SCHEMA_STATS [message #120111 is a reply to message #120067] Tue, 17 May 2005 16:14 Go to previous message
kapil2005
Messages: 44
Registered: March 2005
Member
Well all users in this database are having these privs

ANALYZE ANY
SELECT ANY TABLE
SELECT ANY SEQUENCE
SELECT ANY DICTIONARY
and many other privs that are necessary to connect and access database. and oracle version is 92060. anyways it worked with CASCADE=False, so i am going to gather statistics in old way.
Thank you for your quick responses and your time.
Kapil
Previous Topic: A problem about PB. Thanks
Next Topic: log file sync?
Goto Forum:
  


Current Time: Fri Sep 27 02:20:00 CDT 2024