Analyze and compare the data size of each table in the database

Source: Internet
Author: User
1 . Exec Sp_spaceused ' Table Name '   -- (SQL statistics, which may be inaccurate after a large number of transaction operations)
2 . Exec Sp_spaceused ' Table Name ' , True -- (Update the space size of the table. The exact empty size of the table may take some statistical time)
3 . Exec Sp_spaceused -- (Database size query)
4 . Exec Sp_msforeachtable" Exec Sp_spaceused ' ? ' " -- (Any user tablespace table is small, SQL statistics, and may not be allowed after a large number of transaction operations)
5 . Exec Sp_msforeachtable" Exec Sp_spaceused ' ? ' , True" -- (Any user tablespace table is small, and large databases should be used with caution)

You can view the temporary table.

Create Table # Temp
(
Name Varchar ( 255 ),
Rows Bigint ,
Reserved Varchar ( 20 ),
Data Varchar ( 20 ),
Index_size Varchar ( 20 ),
Unused Varchar ( 20 )
)
Exec Sp_msforeachtable" Insert   Into # Temp   Exec Sp_spaceused ' ? ' "
Select   *   From # Temp   Order   By Data Desc   -- Sort by size
Drop   Table # Temp

View the data file and Log File Size

-- Database size
Sp_helpdb Database Name

--Log Size
DBCC sqlperf (logspace)

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.