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.
asked 23 Jan '14, 12:02
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.