Tuesday, November 23, 2010

SQL - Top15 biggest tables

Using this SQL you will be able to get a list of the top 15 biggest tables in MB and GB.
You can replace the 15 with any number depending on how many results you would like to see.


SQL:

SELECT NAME, size_mb, size_gb
  FROM (SELECT   segment_name NAME,
                 SUM (BYTES) / 1024 / 1024 size_mb,
                 SUM (BYTES) / 1024 / 1024 / 1024 size_gb
        FROM dba_segments
        GROUP BY segment_name
        ORDER BY SUM (BYTES) / 1024 / 1024 DESC)
 WHERE ROWNUM <= 15

1 comment:

  1. Very useful code! I will try to use it in and see the biggest tables in my database.
    Sql training

    ReplyDelete