«

»

Jun 21

Query to find Table Space Utilization in Database

This is the query to find the amount of space which each table occupy in there respective Database.


SELECT
DATABASENAME (TITLE ‘Database’)
,TABLENAME (TITLE ‘Table Name’)
,SUM(CURRENTPERM)/(1024*1024*1024)  (DECIMAL(15,6))  (TITLE ‘Current Perm Space(GB)’)
FROM DBC.TABLESIZE
WHERE DATABASENAME = ‘YOUR_DATABASE_NAME
GROUP BY 1,2
ORDER BY 3 DESC

Where YOUR_DATABASE_NAME is the name of the database for which u need to do the analysis.

This Query will return 3 columns Database, Table Name and Current Perm Space(GB).Based on the analysis of these data we can easily see that how much space each table is occupying in the database.


15 pings

Skip to comment form

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.