BEGIN FOR c IN (SELECT table_name,owner FROM dba_tables WHERE TEMPORARY='N' AND owner='SUPERMAG') LOOP BEGIN EXECUTE IMMEDIATE 'alter table '||c.owner||'.'|| c.table_name || ' enable row movement'; EXECUTE IMMEDIATE 'alter table '||c.owner||'.'|| c.table_name || ' shrink space cascade compact'; EXECUTE IMMEDIATE 'alter table '||c.owner||'.'|| c.table_name || ' shrink space cascade'; EXECUTE IMMEDIATE 'analyze table '||c.owner||'.'|| c.table_name || ' compute statistics for all columns'; EXCEPTION WHEN OTHERS THEN dbms_output.put_line(c.table_name); END; END LOOP; END; /