Sqlsever统计数据小操作

统计Sqlsever数据库中数据的一些小偏方:

 1 #sql server 数表:
 2 
 3 select count(1) from sysobjects where xtype='U'
 4 
 5 #数视图:
 6 
 7 select count(1) from sysobjects where xtype='V'
 8 
 9 #数存储过程
10 
11 select count(1) from sysobjects where xtype='P'
12  
13 
14 
15 SELECT * FROM sysobjects WHERE (xtype = 'U')
16 
17 #C = CHECK 约束 
18 #D = 默认值或 DEFAULT 约束 
19 #F = FOREIGN KEY 约束 
20 #L = 日志 
21 #FN = 标量函数 
22 #IF = 内嵌表函数 
23 #P = 存储过程 
24 #PK = PRIMARY KEY 约束(类型是 K) 
25 #RF = 复制筛选存储过程 
26 #S = 系统表 
27 #TF = 表函数 
28 #TR = 触发器 
29 #U = 用户表 
30 #UQ = UNIQUE 约束(类型是 K) 
31 #V = 视图 
32 #X = 扩展存储过程
33 
34 #这是查询所有表的信息
35 
36 select * from sysobjects where xtype='U'
37 
38 #这是查询表的数量
39 
40 select count(*) from sysobjects where xtype='U' 
41 
42 #这是快速查询所有表中的数据量
43 ‍select a.name, b.rows from sysobjects a with(nolock) join sysindexes b with(nolock) on b.id=a.id where a.xtype='U' and b.indid in (0,1) order by a.name asc 
原文地址:https://www.cnblogs.com/meipu/p/11425250.html