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) 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 :-)

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest