set serveroutput on
set serveroutput on size 1000000
declare
sql_string varchar2(2000);
CURSOR OBJ IS
select owner,table_name
from dba_tables
where last_analyzed is null
--and OWNER='&owner'
;
begin
for REC1 IN OBJ LOOP
DBMS_OUTPUT.PUT_LINE('EXEC DBMS_STATS.GATHER_TABLE_STATS ('''||REC1.owner||''','''||REC1.table_name||''');');
END LOOP;
END;
/