need help with PL/SQL
I want to get the table names where the count (*) is different by num_rows by 20000 rows . Then I can analyze these tables . I have put the logic there , need some help with the code .
c num ,
select table_name from user_tables into a where owner='SYSTEM',
select count(*) from a into b;
select num_rows into c from user_tables where table_name = a;
If b > c + 20000
PRINT ' a'
Alternatively, you could ...
ownname => 'MY_SCHEMA'
... for all your tables in the schema, then periodically run ...
options => 'GATHER STALE',
... which would hand over the task of deciding what tables needed re-analyzing to Oracle.
Last edited by slimdave; 05-12-2003 at 02:57 PM.
Set pages 0
Select 'Select ' || ''' Analyze Table ' || owner || '.' || table_name || ' Compute statistics;''' || ' from dual ' ||
' Where ' || num_rows || ' > (Select count(*) + 2000 from ' || owner || '.' || table_name || ');'
Set pages 50
Márcio de Souza Almeida
DBA Oracle / SQLServer / PostgreSQL
Rua Cupa, 139 Apto 85 A
Penha - São Paulo - SP
03640-000 - Brasil
Click Here to Expand Forum to Full Width