SELECT
  OWNER,
  OBJECT_NAME,
  OBJECT_TYPE,
  ALLOC_MB,
  PERCENT
FROM
( SELECT
    OWNER,
    NVL(OBJECT_NAME, DECODE(DATA_OBJECT_ID, 0, '0 (UNUSED)',
      TO_CHAR(DATA_OBJECT_ID) || ' (UNDO?)')) OBJECT_NAME,
    OBJECT_TYPE,
    TO_CHAR(BLOCKS * 8192 / 1024 / 1024, 99990.99) ALLOC_MB,
    TO_CHAR(RATIO_TO_REPORT(BLOCKS) OVER () * 100, 990.99) PERCENT
  FROM
  ( SELECT
      O.OWNER OWNER,
      O.OBJECT_NAME OBJECT_NAME,
      O.OBJECT_TYPE OBJECT_TYPE,
      B.OBJD DATA_OBJECT_ID,
      COUNT(*) BLOCKS,
      ROW_NUMBER() OVER (PARTITION BY O.DATA_OBJECT_ID
        ORDER BY O.OBJECT_TYPE) CLUSTRN
    FROM
      DBA_OBJECTS O,
      V$BH B
    WHERE
      O.DATA_OBJECT_ID (+) = B.OBJD
    GROUP BY
      B.OBJD,
      O.OWNER,
      O.OBJECT_NAME,
      O.OBJECT_TYPE,
      O.DATA_OBJECT_ID
  )
  WHERE
    CLUSTRN = 1
  ORDER BY
    BLOCKS DESC
)
WHERE
  ROWNUM <= 20;

