Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Top 10 tablespaces

DBA112May 3 2012 — edited May 3 2012
Hello All,

Need help with below:

I need to fetch top 10 tablespaces by size from each of the production databases we have. For this, we built customized table (DBA_MAINT.prod_tbsp_info). TARGET_NAME is the DB name

SQL> desc dba_maint.prod_tbsp_info
Name Null? Type
----------------------------------------------------------------------------------- -------- --------------------------------------------------------
TARGET_NAME NOT NULL VARCHAR2(9)
COLLECTION_TS NOT NULL DATE
TBSP_NAME NOT NULL VARCHAR2(50)
AUTOEXT NOT NULL VARCHAR2(5)
BIGFILE NOT NULL VARCHAR2(5)
BLOCK_SIZE NUMBER
DBF_COUNT NUMBER
SIZE_MB NUMBER
USED_MB NUMBER
FREE_MB NUMBER
MAXEXT_MB NUMBER
PCT_FREE NUMBER

The below query gives me complete list of tablespaces from each database. However, I need only top 10 TS by size. I need to use rownum, but not sure how the syntax would be to fetch TOP 10 TS from each database.

select TARGET_NAME, TBSP_NAME, SIZE_MB from dba_maint.prod_tbsp_info
where TARGET_NAME in (select distinct TARGET_NAME from dba_maint.prod_tbsp_info)
AND COLLECTION_TS = trunc(sysdate) - 2
order by TARGET_NAME;

Greatly appreciate your help

Thanks
Shanthan
This post has been answered by 713555 on May 3 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 31 2012
Added on May 3 2012
16 comments
619 views