zoukankan      html  css  js  c++  java
  • 常用sqlserver 查询DB状态的语句

    1. 查各个表占用空间以及记录数

    select object_name(id) as tablename,8*reserved/1024 as reserved,
    rtrim(8*dpages/1024)+'Mb' as used,8*(reserved-dpages)/1024 as unused,
    8*dpages/1024-rows/1024*minlen/1024 as free, rows from sysindexes
    where indid=1 and object_name(id) like 'dnt%' order by sysindexes.rows desc

    2. 把各个表的所有char/varchar列找出来 

    nchar(type=47 and xtype=239),

    char(type=47 and xtype=175)

    nvarchar(type=39 and xtype=231)

    varchar(type=39 and xtype=167)
    select object_name(id) as tablename, name,
    case xtype
    when 239 then 'nchar'
    when 175 then 'char'
    when 231 then 'nvarchar'
    when 167 then 'varchar'
    end as chartype from sys.syscolumns
    where object_name(id) like 'dnt_%' and ((type=47 and xtype=175)
    or (type=39 and xtype=167))
    order by object_name(id),colorder
      
  • 相关阅读:
    取球问题
    汉字首字母
    上三角
    循环小数
    拓扑排序
    倒水
    equals方法使用技巧
    Java库中的集合
    win10安装Redis方法以及基本配置
    c、c++函数随机
  • 原文地址:https://www.cnblogs.com/zitjubiz/p/Sqlserver_Stat_query.html
Copyright © 2011-2022 走看看