Teradata : Get databases size in GB

Databases size in GB

The size of database is the diffrence of maxperm and currentperm space of a database. select the sum of maxperm and currentperm from DBC.DISKSPACE and convert into GB and get the difference. Below is the query to find database size in GB

select databasename,cast(sum(maxperm)/1024 ** 3 as decimal(7,2))  max_perm_GB,
cast(sum(currentperm)/1024 **3 as decimal(7,2)) current_perm_GB,
max_perm_GB – current_perm_GB   free_space_GB
from dbc.diskspace
where databasename in  (select databasename from dbc.databases where dbkind = ‘D’)
—  where  databasename=’DATABASE_NAME’
group by databasename order by free_space_GB  desc;

 

Here the  sum of maxperm and currentperm is divided 3 times by 1024 to convert into GB. Two minus sign (–) is used to comment the line in SQL Assistant. you can uncomment below where clause and comment upper where clause and specify a database name to get the size of specific database.


Leave a comment