To gather any statistics

On any schema, you’d need an any-privilege…
Which so happens to be: ANALYZE ANY DICTIONARY and ANALYZE ANY

So, give these to user you want to call the dbms_stats package and all will be fine…

In this case, I created this tiny script:

   echo "connect user/passw@sid"
   echo "exec dbms_stats.gather_schema_stats('SCHEMA', estimate_percent => 15%, cascade => true);"
 ) | sqlplus /nolog


Execute this in the background and you’re done.

Comments are closed.