2011年9月7日水曜日

generate table row count statistics script

generate table row count statistics script. (should delete first 'union all')
with create table, we needn't worry about the interruption and rollback. it doesn't lock any table or row, neither generate overload on rollback processing.

set echo off;
set verify off;
set feedback off;
spool table_stat_script.sql;

select 'create table table_stats as' from dual;
select 'union all select /*+ parallel(a) */'''||(select name from v$database)||''' db_name, '''||owner||''' owner,'''||table_name||''' table_name, count(*) cnt from '||owner||'.'||table_name||' a'

from dba_tables where owner = '&owner' order by owner, table_name;

spool off;

@table_stat_script.sql

0 件のコメント:

コメントを投稿