Get size of all tables in database
Database in of get all size tables
2023-09-11 14:14:17 时间
Get size of all tables in database
回答1
SELECT t.NAME AS TableName, s.Name AS SchemaName, p.rows, SUM(a.total_pages) * 8 AS TotalSpaceKB, CAST(ROUND(((SUM(a.total_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS TotalSpaceMB, SUM(a.used_pages) * 8 AS UsedSpaceKB, CAST(ROUND(((SUM(a.used_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS UsedSpaceMB, (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB, CAST(ROUND(((SUM(a.total_pages) - SUM(a.used_pages)) * 8) / 1024.00, 2) AS NUMERIC(36, 2)) AS UnusedSpaceMB FROM sys.tables t INNER JOIN sys.indexes i ON t.OBJECT_ID = i.object_id INNER JOIN sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id INNER JOIN sys.allocation_units a ON p.partition_id = a.container_id LEFT OUTER JOIN sys.schemas s ON t.schema_id = s.schema_id WHERE t.NAME NOT LIKE 'dt%' AND t.is_ms_shipped = 0 AND i.OBJECT_ID > 255 GROUP BY t.Name, s.Name, p.Rows ORDER BY TotalSpaceMB DESC, t.Name
回答2
Open your Databases
> and select Tables,
Then press key F7
You should see the row count
相关文章
- Entity Framework 7 Database First configuration (MVC 6)
- SQL Server: Database stuck in “Restoring” state
- CREATE DATABASE
- SQL Change Automation --> Setting up a project with an existing database in SSMS
- Database ORM
- 第八十六章 SQL命令 USE DATABASE
- 【英文讲座】Paradigm Shift to Enterprise In-Memory Database Era...
- How To Backup and Restore PostgreSQL Database using pg_dump and psql
- ORA-01102: cannot mount database in EXCLUSIVE mode
- cannot mount database in EXCLUSIVE mode
- 【Database】关于SQL Server
- User PUBLIC is detected Username Detected In Active Session on Standby database
- 转 LIST INCARNATION OF DATABASE
- Plugging an Unplugged Pluggable Database issue 2
- Clone a Pluggable Database – 12c Edition
- In PyTorch 1.1.0 and later, you should call them in the opposite order: `optimizer.step()` before `l
- 数据库(database)介绍
- Oracle Database 12c - Global Data Services
- 闪回数据库(Flashback Database)
- Database returned an invalid value in QuerySet.datetimes(). Are time zone definitions for your datab
- 事务日志备份失败错误:Backup detected log corruption in database
- How to select a OptionSet on ms sqlserver database for Microsoft Dynamics CRM
- 基于自动配置jar包和SpringBoot以及注解一分钟快速搭建企业项目开发环境,主要包含DataBase、mybatis、Dubbo、log4j、RabbitMQ、redis及相关客户端配置等等
- spring boot Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection;