cancel
Showing results for 
Search instead for 
Did you mean: 

How to know DATABASE size???

Former Member
3,799

Hi folks,

I would like to know which command I use to know database physical size. In SQL Server I can use sp_helpdb ou sp_spaceused. Is there any command like these?

Also, any command to know the dbpsace allocated size and the file size.

Thanks! Roger

Accepted Solutions (1)

Accepted Solutions (1)

VolkerBarth
Contributor

I don't know whether this is the easiest way for a running database, but you can calculate that with the database properties FileSize (number of database pages) and PageSize (size of a database page), say in MB - for the system dbspace (i.e. the database .db file):

select db_property('FileSize') * db_property('PageSize') / 1024 / 1024;

and accordingly for other dbspaces like the transaction log (.log):

select db_extended_property('FileSize', 'TransLog') * db_property('PageSize') / 1024 / 1024;

Note: This tells the whole size of these files, not the "used space" vs. free space. There are other properties for that, or the DBINFO utility.

Answers (0)