SQL 中怎么查询一个数据库中一共有多少个表

用户表:select count(*) 总表数 from sysobjects where xtype=’u’

刚才那个是用户表,下面这个是系统表加用户表:

select count(*) 总表数 from sysobject s where xtype in(‘u’,’s’)
总视图数:select count(*) 总视图数 from sysobjects where xtype=’v’
总存储过程数:select count(*) 总存储过程数 from sysobjects where xtype=’p’
总触发器数:select count(*) 总触发器数 from sysobjects where xtype=’tr’
数据库作业: SELECT count(*) FROM msdb.dbo.sysjobs
sysobjects 表参数说明—-
D = 默认值或 DEFAULT 约束
F = FOREIGN KEY 约束
L = 日志
FN = 标量函数
IF = 内嵌表函数
P = 存储过程
PK = PRIMARY KEY 约束(类型是 K)
RF = 复制筛选存储过程
S = 系统表
TF = 表函数
TR = 触发器
U = 用户表
UQ = UNIQUE 约束(类型是 K)
V = 视图
X = 扩展存储过程

Leave a Comment

 
Copyright © 2008-2021 lanxinbase.com Rights Reserved. | 粤ICP备14086738号-3 |