在MS SQL Server中,可通过如下语句查询相关系统信息,如:
使用:
Select name from sysobjects where xtype=’U’;
可得到所有用户表的名称;
Select name from sysobjects where xtype=’S’;
得到所有系统表的名称;
相应的,使用:
Select count(*)-1 from sysobjects where xtype=’U’;
得到用户表的张数。
上面之所以要减1,是因为在SQLServer2000中,有一系统表:dtproperties被标记为了用户表,这或许是SQLServer2000中的一个BUG,在2005中,就不存在该表了,而是用表:sysdiagram代替,该表是用来存储数据关系图
可通过:
Select @@version;
查询数据库的版本
可通过如下语句提取用户表的描述或列的描述,该描述全放在一个叫做sysproperties的系统表中
select sysobjects.name, sysproperties.Value from sysproperties,sysobjects where sysproperties.id=sysobjects.id and sysproperties.name='MS_Description' and sysproperties.type='3' order by sysobjects.name
在该表中,id 列与sysobjects中的id列是对应的,当该表的type值为3时,是对表的描述,为4,是对列的描述
阅读全文 | 回复(0) | 引用通告 | 编辑 |