--查看所有表的大小
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查看所有表的大小的更多相关文章

  1. sql查看所有表大小的方法

    sql查看所有表大小的方法. 代码: declare @id int ) declare @pages int declare @dbname sysname ,) ,) ,) create tabl ...

  2. MySQL查看数据库表容量大小

    本文介绍MySQL查看数据库表容量大小的命令语句,提供完整查询语句及实例,方便大家学习使用. 1.查看所有数据库容量大小 select table_schema as '数据库', sum(table ...

  3. SQL 查看数据库表的容量大小

    --==============查看数据库表的容量大小========start================================?============ Create Table # ...

  4. MySQL查看库表的大小

    MySQL数据库空间使用情况查询 如果想知道MySQL数据库中每个表占用的空间.表记录的行数的话,可以打开MySQL的 information_schema 数据库.在该库中有一个 TABLES 表, ...

  5. 【Oracle】查看oracle表空间大小及增加表空间的几种方法

    在oracle中表空间是必不可少的.但是怎么查看表空间呢 简单的查看方式是: SQL> select tablespace_name from dba_tablespaces; 想要查看表空间对 ...

  6. SQL Server 查看数据表占用空间大小的SQL语句

    ) ) if object_id('tempdb..#space') is not null drop table #space ),rows ),data ),index_size ),unused ...

  7. MySQL数据库查看数据表占用空间大小和记录数

    MySQL数据库中每个表占用的空间.表记录的行数的话,可以打开MySQL的 information_schema 数据库.在该库中有一个 TABLES 表,这个表主要字段分别是: TABLE_SCHE ...

  8. Sql:查看数据库表和表结构的语句

    T-sql 显示表结构和字段信息的sql语句: exec sp_help tablename; ~~使用存储过程 sp_help 显示数据库包含哪些表的sql语句: use yourDBname;se ...

  9. mysql查看各个表的大小

    information_schema 数据库,在该库中有一个 TABLES 表,这个表主要字段分别是: TABLE_SCHEMA : 数据库名 TABLE_NAME:表名 ENGINE:所使用的存储引 ...

随机推荐

  1. 修改mac下homebrew的源 加快下载速度

    把源改为清华的镜像 # HOMEBREW_BOTTLE_DOMAIN就是目标源 修改这个路径就可以里 echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirro ...

  2. p5339 [TJOI2019]唱、跳、rap和篮球

    分析  代码 #include<bits/stdc++.h> using namespace std; #define int long long ; ; ],inv[],G,cc[][] ...

  3. Mac下用命令行压缩和解压rar文件的方法

    废话不多说,直接进入主题 第一步:下载RAR工具包,根据自己需要下载相对应的版本 第二步:解压对应的压在的压缩包rarosx-5.4.0.tar.gz(我下载的是5.4.0版本) 第三步:从终端进入到 ...

  4. Note:目录1

    ylbtech-Note:目录1 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返回顶部   作者:ylbtech出处:http://ylbtech ...

  5. CVTRES : fatal error CVT1100: duplicate resource

    升级某些VC6工程到VS2017,除了目录问题外,就是这个. 解决方法: Properties > Linker > Manifest File 第一项,Generate Manifest ...

  6. 认识requests库,以及安装方法

    1.学习requests库有什么意义 1)对我来说,我是测试人员,我用它来解决HTTP接口自动化测试 2)写爬虫需要用到requests 3)如果是开发人员,需要些接口,了解requests有助于掌握 ...

  7. Jenkins设置默用户为root

    https://www.jianshu.com/p/181dfb259dc7 最近在需要在jenkins执行shell脚本,由于Jenkins之前是默认在线安装的,这样jenkins设置了默认用户je ...

  8. jmeter 非GUI执行测试,没有响应数据保存到jtl文件办法

    估计是jmeter为了减轻客户机负担,就没又默认把这些信息保存,如果想要保存,也可以,需要做出如下配置: 修改bin目录下的user.properties文件,追加配置: jmeter.save.sa ...

  9. javascript的继承模式

    在javascript里面看到javascript的继承模式和传统的继承模式是有区别的,就想查资料看一下到底有区别,就看到了这篇文章,觉得讲得还可以,暂时先放上来,以后有别的东西再补充: http:/ ...

  10. vue + element 创建教程

    一.环境准备 node安装 node版本:v10.15.3 node下载地址:https://nodejs.org/zh-cn/ vue-cli安装 全局安装vue-cli npm install - ...