Home » RDBMS Server » Server Administration » Privileges required to gather stats on tables in another schema
Privileges required to gather stats on tables in another schema [message #174122] Fri, 26 May 2006 00:36 Go to next message
kumarsz
Messages: 180
Registered: March 2005
Location: canada
Senior Member
Hi,
Oracle 9.2.0.6.0
I want to collect statistics of table using following procedure
CREATE OR REPLACE PROCEDURE table_stats
AS
BEGIN
FOR c_tbl_nm IN (SELECT table_name
FROM dba_tables where OWNER = 'USER2')
LOOP
DBMS_STATS.gather_table_stats
('USER2',
UPPER (c_tbl_nm.table_name),
method_opt => 'For all indexed columns size 50',
CASCADE => TRUE
);
END LOOP;
END;
/

The above procedure is created in USER1 schema and user1 only will be excuting it.
However inspite of the fact that user1 has SYSDBA role,Alter any table SYStem Privilege and all object privileges on all tables in USER2 schema,
while excuting above procedure i am getting following error
*
ERROR at line 1:
ORA-20000: Object BZ_ERROR_HISTORY does not exist or insufficient privileges
to analyze
ORA-06512: at "SYS.DBMS_STATS", line 10070
ORA-06512: at "SYS.DBMS_STATS", line 10084
ORA-06512: at "USER1.TABLE_STATS", line 7
ORA-06512: at line 1

here "BZ_ERROR_HISTORY" is table in USER2 schema

Please suggst whether any further privileges are required by USer1 to run the above procedure on USER2 tables.

Thanks in Advance,
Pratap

Re: Privileges required to gather stats on tables in another schema [message #174153 is a reply to message #174122] Fri, 26 May 2006 04:24 Go to previous messageGo to next message
orausern
Messages: 826
Registered: December 2005
Senior Member
is the code posted the actual code getting the error? -in that case its syntax needs to be changed for the FIRST TWO parameters..

Quote:


DBMS_STATS.gather_table_stats
('USER2',
UPPER (c_tbl_nm.table_name),
method_opt => 'For all indexed columns size 50',
CASCADE => TRUE
);



should be


DBMS_STATS.gather_table_stats
(ownname=>'USER2',
tabname=>UPPER (c_tbl_nm.table_name),
method_opt => 'For all indexed columns size 50',
CASCADE => TRUE
);

Re: Privileges required to gather stats on tables in another schema [message #174179 is a reply to message #174122] Fri, 26 May 2006 06:41 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
You dont need sysdba privs.
All you need is select any table privilege.
This might be your case.
http://www.orafaq.com/forum/?t=rview&goto=172707#msg_172707
Re: Privileges required to gather stats on tables in another schema [message #174195 is a reply to message #174122] Fri, 26 May 2006 07:12 Go to previous message
kumarsz
Messages: 180
Registered: March 2005
Location: canada
Senior Member
Hello Mahesh,
i will try with 'Select Any Table'

At moment it worked with 'Analyze any table' system privilege.

Many thanks for Your Input

Regards,
Pratap
Previous Topic: Checkpoint
Next Topic: oracle services
Goto Forum:
  


Current Time: Fri Sep 20 12:53:17 CDT 2024