Skip to Main Content

SQL & PL/SQL

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Equal distribution into buckets

DBAPEXNov 29 2018 — edited Nov 30 2018

Hello experts, I have a problem where I depend on your expertise.

I have a query that returns all user tables and their sizes.

My aim is to distribute all tables into 6 buckets with a maximum size of 500G each.

Can you please give me an example of how to achieve that? I am not yet that familiar with analytical functions.

Did some stuff with 10g but since then no longer. And 12c, which I am using nowadays might offer more convenient ways.

However, to be honest, I do not even have an idea how to create those buckets with an older Oracle release.

Maybe you can give me some advice.

select owner, segment_name, gr_mb,

round(RATIO_TO_REPORT(gr_mb) over (partition by 1) * 100,2) perc_total_size,

sum(gr_mb) over (partition by 1) total_size

from (

select owner, segment_name, round(bytes/1024/1024/1024) gr_mb

from dba_segments

where owner like 'SCH%' and segment_type = 'TABLE' and segment_name not like 'BIN$%'

order by bytes desc

)

This post has been answered by mathguy on Nov 29 2018
Jump to Answer

Comments

Post Details

Added on Nov 29 2018
40 comments
2,028 views