SQL查看所有表的大小
--查看所有表的大小
declare @id int declare @type character(2) declare @pages int declare @dbname sysname declare @dbsize dec(15,0) declare @bytesperpage dec(15,0) declare @pagesperMB dec(15,0) create table #spt_space ( [objid] int null, [rows] int null, [reserved] dec(15) null, [data] dec(15) null, [indexp] dec(15) null, [unused] dec(15) null ) set nocount on -- Create a cursor to loop through the user tables declare c_tables cursor for select id from sysobjects where xtype = 'U' open c_tables fetch next from c_tables into @id while @@fetch_status = 0 begin /* Code from sp_spaceused */ insert into #spt_space (objid, reserved) select objid = @id, sum(reserved) from sysindexes where indid in (0, 1, 255) and id = @id select @pages = sum(dpages) from sysindexes where indid < 2 and id = @id select @pages = @pages + isnull(sum(used), 0) from sysindexes where indid = 255 and id = @id update #spt_space set data = @pages where objid = @id /* index: sum(used) where indid in (0, 1, 255) - data */ update #spt_space set indexp = (select sum(used) from sysindexes where indid in (0, 1, 255) and id = @id) - data where objid = @id /* unused: sum(reserved) - sum(used) where indid in (0, 1, 255) */ update #spt_space set unused = reserved - ( select sum(used) from sysindexes where indid in (0, 1, 255) and id = @id ) where objid = @id update #spt_space set [rows] = i.[rows] from sysindexes i where i.indid < 2 and i.id = @id and objid = @id fetch next from c_tables into @id end select TableName = (select left(name,60) from sysobjects where id = objid), [Rows] = convert(char(11), rows), ReservedKB = ltrim(str(reserved * d.low / 1024.,15,0) + ' ' + 'KB'), DataKB = ltrim(str(data * d.low / 1024.,15,0) + ' ' + 'KB'), IndexSizeKB = ltrim(str(indexp * d.low / 1024.,15,0) + ' ' + 'KB'), UnusedKB = ltrim(str(unused * d.low / 1024.,15,0) + ' ' + 'KB') from #spt_space, master.dbo.spt_values d where d.number = 1 and d.type = 'E' order by reserved desc drop table #spt_space close c_tables deallocate c_tables
SQL查看所有表的大小的更多相关文章
- sql查看所有表大小的方法
sql查看所有表大小的方法. 代码: declare @id int ) declare @pages int declare @dbname sysname ,) ,) ,) create tabl ...
- MySQL查看数据库表容量大小
本文介绍MySQL查看数据库表容量大小的命令语句,提供完整查询语句及实例,方便大家学习使用. 1.查看所有数据库容量大小 select table_schema as '数据库', sum(table ...
- SQL 查看数据库表的容量大小
--==============查看数据库表的容量大小========start================================?============ Create Table # ...
- MySQL查看库表的大小
MySQL数据库空间使用情况查询 如果想知道MySQL数据库中每个表占用的空间.表记录的行数的话,可以打开MySQL的 information_schema 数据库.在该库中有一个 TABLES 表, ...
- 【Oracle】查看oracle表空间大小及增加表空间的几种方法
在oracle中表空间是必不可少的.但是怎么查看表空间呢 简单的查看方式是: SQL> select tablespace_name from dba_tablespaces; 想要查看表空间对 ...
- SQL Server 查看数据表占用空间大小的SQL语句
) ) if object_id('tempdb..#space') is not null drop table #space ),rows ),data ),index_size ),unused ...
- MySQL数据库查看数据表占用空间大小和记录数
MySQL数据库中每个表占用的空间.表记录的行数的话,可以打开MySQL的 information_schema 数据库.在该库中有一个 TABLES 表,这个表主要字段分别是: TABLE_SCHE ...
- Sql:查看数据库表和表结构的语句
T-sql 显示表结构和字段信息的sql语句: exec sp_help tablename; ~~使用存储过程 sp_help 显示数据库包含哪些表的sql语句: use yourDBname;se ...
- mysql查看各个表的大小
information_schema 数据库,在该库中有一个 TABLES 表,这个表主要字段分别是: TABLE_SCHEMA : 数据库名 TABLE_NAME:表名 ENGINE:所使用的存储引 ...
随机推荐
- Jsoup代码示例、解析网页+提取文本
使用Jsoup解析HTML 那么我们就必须用到HttpClient先获取到html 同样我们引入HttpClient相关jar包 以及commonIO的jar包 我们把httpClient的基本代码写 ...
- EZOJ #389点分治好题
分析 一层一层把叶子去掉 看最多能去掉多少层即可 代码 #include<bits/stdc++.h> using namespace std; ],du[],fa[],n,m,ans; ...
- 批处理脚本学习笔记1--vmware虚拟机启停控制
起因 因工作需要,在WIN10笔记本上通过vmware workstation装了两台CentOS虚机(CentOS_1.CentOS_2),经常需要进行虚机的启停切换操作,通过vmware的控制台操 ...
- 【ABAP系列】SAP ABAP与Java数据类型的对应关系
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP与Java数据类 ...
- 阻塞进程函数 wait()和waitpid()
1. wait()和waitpid()函数说明 wait() 进程一旦调用了wait(), 就立即阻塞自己,由wait自动分析是否有当前进程的某个子进程已经退出,如果让它找到了一个已经变成僵尸的子进 ...
- 编程语言 - 脚本编程 - JavaScript/Jquery/Ajax/XML/JSON/ActionScript3
事件处理onmouseover <!DOCTYPE html> <html> <head> <meta charset="utf-8"&g ...
- SQL常用语句之数据库的创建、删除以及属性的修改-篇幅1
本篇文章主要总结了SQL Server 语句的使用和一些基础知识,因为目前我也正在学习,所以总结一下. 要使用数据库语句,首先就要知道数据库对象的结构: 通常情况下,如果不会引起混淆,可以直接使用对象 ...
- Windows禅道环境部署
1. 禅道下载地址,下载解压 http://www.zentao.net/download/80081.html 一键安装包根据本机系统做相应版本下载 2. 解压完打开文件夹xampp ...
- 记录XorDDos木马清理步骤
1.检查 查看定时任务文件发现有两个异常定时任务 [root@manage ~]# cat /etc/crontab # * * * * * user-name command to be execu ...
- [Codeforces 555E]Case of Computer Network(Tarjan求边-双连通分量+树上差分)
[Codeforces 555E]Case of Computer Network(Tarjan求边-双连通分量+树上差分) 题面 给出一个无向图,以及q条有向路径.问是否存在一种给边定向的方案,使得 ...