Oracle Sql Query: Dba_Segments + Dba_Objects
I Wish to Modify This Sql to Add the Max(Created) and Max(Last_Ddl_Time) from Dba_Objects. How Do I Do That? Thank You. Select Owner, Segment_Name, Sum(Bytes)...
I wish to modify this sql to add the max(created) and max(last_ddl_time) from dba_objects. How do I do that ? Thank you.
select owner, segment_name, sum(bytes) sb
from dba_segments
where tablespace_name = 'USERS'
group by owner, segment_name order by sb desc
1 Answer
Like this:
select ds.owner,ds.segment_name,sum(ds.bytes) sb,
max(do.created) mc, max(do.last_ddl_time) md
from dba_segments ds join dba_objects do
on (ds.owner=do.owner and ds.segment_name=do.object_name)
where tablespace_name = 'USERS'
group by ds.owner, ds.segment_name
order by sb desc;
If this makes sense is another matter :-)