zoukankan      html  css  js  c++  java
  • 数据库表格所占空间及索引所占空间情况

    set nocount on 
    exec sp_MSForEachTable 
    @precommand=N'
    create table ##(
    id int identity,
    表名 sysname,
    字段数 int,
    记录数 int,
    保留空间 Nvarchar(20),
    使用空间 varchar(20),
    索引使用空间 varchar(20),
    未用空间 varchar(20))',
    @command1=N'insert ##(表名,记录数,保留空间,使用空间,索引使用空间,未用空间) exec sp_spaceused ''?''
            update ## set 字段数=(select count(*) from syscolumns where id=object_id(''?'')) where id=scope_identity()',
    @postcommand=N'select 
    	id,
    	表名,
    	字段数 列数,
    	(记录数/10000.0) 记录数万,
    	(Convert(bigint,rtrim(Replace(保留空间,''KB'','''')))/1024.0) 保留空间M,
    	(Convert(bigint,rtrim(Replace(使用空间,''KB'','''')))/1024.0) 使用空间M,
    	(Convert(bigint,rtrim(Replace(索引使用空间,''KB'','''')))/1024.0) 索引使用空间M,
    	(Convert(bigint,rtrim(Replace(未用空间,''KB'','''')))/1024.0) 未用空间M
     from ## a order by 使用空间M desc;
     drop table ##'
    set nocount off
    

      

  • 相关阅读:
    《我曾》火了:人这辈子,最怕突然听懂这首歌
    SpringMVC的运行流程
    Directive 自定义指令
    Vue 过滤器
    MVC 和 MVVM的区别
    vue指令
    async
    Generator
    单词搜索
    Promise
  • 原文地址:https://www.cnblogs.com/cxd4321/p/3664390.html
Copyright © 2011-2022 走看看