大于10M表无统计信息的收集
begin
for r in (select tab.owner,tab.TABLE_NAME
from dba_tables tab, dba_segments seg
where tab.TABLE_NAME = seg.segment_name
and tab.OWNER = seg.owner
and seg.segment_type = 'TABLE'
and tab.LAST_ANALYZED is null
and tab.NUM_ROWS=0
and tab.owner in('TBCS')
and seg.bytes / 1024 / 1024 > 10)
loop
begin dbms_output.put_line('exec dbms_stats.GATHER_TABLE_STATS(OWNNAME=>'||''''||r.owner||''''||',TABNAME=>'||''''||r.table_name||''''||',cascade=>TRUE);');
end;
end loop;
end;
/
PL/SQL中两个单引号会输出一个单引号
begin
for r in (select tablespace_name from dba_data_files where online_status='OFFLINE')
loop
begin dbms_output.put_line('select dbms_metadata.get_ddl(''TABLESPACE'','||''''||r.tablespace_name||''''||') from dual;');
end;
end loop;
end;
/