首页 > 数据库技术 > 详细

SQL Server —— 查询数据库、表、列等

时间:2017-09-05 15:23:03      阅读:194      评论:0      收藏:0      [点我收藏+]

一、查询数据库(sys.databases —— select *from sys.databases where name=‘<数据库名>‘)

select *from sys.databases where name=MyDatabase

技术分享

二、查询表(sysobjects —— select *from sysobjects where id=OBJECT_ID(‘<表名>‘))

select *from sysobjects where id=OBJECT_ID(StudentsInfo)

技术分享

三、查询列(syscolumns —— select COUNT(*) from syscolumns where name=‘<列名>‘ and id=OBJECT_ID(‘<表名>‘))

select COUNT(*) from syscolumns where name=sname and id=OBJECT_ID(studentsinfo)

技术分享

 四、查询存储过程或视图(select * from sysobjects where name=‘<视图或存储过程名>‘  AND  type  =  ‘P/V‘)

SQL Server —— 查询数据库、表、列等

原文:http://www.cnblogs.com/qq450867541/p/7478633.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!