col OWNER for A10
col OBJECT_NAME for A30
col SAVTIME for A30
col ANALYZETIME for A30
col DESCRIPTION for A12
define t_owner=&1
define t_table=&2
SELECT b.owner, b.object_name, a.savtime, a.rowcnt,a.analyzetime,'' as description
FROM SYS.WRI$_OPTSTAT_TAB_HISTORY a, DBA_OBJECTS b
WHERE b.owner=upper('&t_owner')
and b.object_name=upper('&t_table')
and b.object_type='TABLE'
and a.obj#=b.object_id
union
select owner, table_name, last_analyzed, num_rows, last_analyzed, 'Current'
from dba_tables
where owner=upper('&t_owner')
and table_name=upper('&t_table')
order by analyzetime asc
OWNER OBJECT_NAME SAVTIME ROWCNT
ANALYZETIME DESCRIPTION
---------- ---------------- ------------- ---------------------- -------- ---------- -----------
HR EMP_TABLE 06-FEB-22 03.05.10.759354 AM -07:00 0 30-JAN-22
HR EMP_TABLE 13-FEB-22 03.05.25.624929 AM -07:00 50 06-FEB-22
HR EMP_TABLE 20-FEB-22 03.05.05.682130 AM -07:00 50 13-FEB-22
HR EMP_TABLE 27-FEB-22 03.05.07.798323 AM -07:00 100 20-FEB-22
HR EMP_TABLE 06-MAR-22 03.05.10.000000 AM -07:00 10000 27-FEB-22
HR EMP_TABLE 06-MAR-22 03.05.10.796727 AM -07:00 50 06-MAR-22 Current