• sqlserver常用sql


    查询某个schema下所有表:

    select * from schema..sysobjects where xtype='U'

    若表明为数字等特殊表名,可以加[ ]:

    select * from shema..[1001]

    查询某个shema下所有表的行数:

    SELECT a.name, b.rows
    FROM schema..sysobjects AS a INNER JOIN schema..sysindexes AS b ON a.id = b.id
    WHERE (a.xtype = 'U') AND (b.indid IN (0, 1))
    ORDER BY a.name,b.rows DESC

    查询某个shema下所有表名和空间使用情况以及行数:

    select
    object_name(id) tablename,
    8*reserved/1024 reserved,
    rtrim(8*dpages)+'kb' used,
    8*(reserved-dpages)/1024 unused,
    8*dpages/1024-rows/1024*minlen/1024 free,
    rows
    from sysindexes
    where indid=1
    order by tablename,reserved desc
  • 相关阅读:
    Python 学习目录
    Django目录
    SQLAlchemy
    Flask之Sqlalchemy
    Websocket
    Mongodb
    虚拟环境
    Github
    LINUX
    内存管理和垃圾回收机制
  • 原文地址:https://www.cnblogs.com/jvStarBlog/p/14806458.html
Copyright © 2020-2023  润新知