SQL Server View table information

Source: Internet
Author: User

1. sp_spaceused

Calculates the amount of disk space used by the data and index and the amount of disk space used by the tables in the current database. If no objname is given,sp_spaceused reports the space used by the entire current database.

Grammar

sp_spaceused [[@objname =] 'objname']
[,[@updateusage =] 'updateusage']

Example:

EXEC sp_spaceused Tbl1000,true

If objnameis omitted, two result sets are returned.

Column Name Data Type Description
database_name varchar (18) The name of the current database.
Database_size varchar (18) The size of the current database.
Unallocated space varchar (18) Unallocated space for the database.

Column Name Data Type Description
Reserved varchar (18) The total amount of space reserved.
Data varchar (18) The total amount of space used by the data.
Index_size varchar (18) The space used by the index.
Unused varchar (18) The amount of unused space.

2. sys.dm_db_index_physical_stats

Returns the size and fragmentation information for the data and indexes of the specified table or view. Grammar
Sys.dm_db_index_physical_stats (     {database_id | NULL | 0 | DEFAULT}  , {object_id | NULL | 0 | DEFAULT}  , {index_id | NULL | 0 | -1 | DEFAULT}  , {partition_number | NULL | 0 | DEFAULT}  , {mode | NULL | DEFAULT})

Example

SELECT Index_type_desc, Alloc_unit_type_desc, Index_depth, Page_count, Record_countfrom Sys.dm_db_index_physical_ Stats (db_id (), object_id (' dbo. Tbl1000 '), Null,null, ' SAMPLED ');

Msdn:https://msdn.microsoft.com/zh-cn/library/ms188917%28v=sql.105%29.aspx

SQL Server View table information

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.