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
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步