数据库 查询字段

txw1958 阅读:69 2022-09-29 09:59:29 评论:0

--查看所有表名:
select name from sysobjects where type='U'


--查询表的所有字段名:

Select name from syscolumns Where ID=OBJECT_ID('表名')


select * from information_schema.tables

select * from information_schema.views

select * from information_schema.columns


--表的字段名称
select name from syscolumns where id=object_id( '表名 ')
--表的字段数
select count(name) from syscolumns where id=object_id( '表名 ')
最好改成:object_id(N '表名 ')
这样只是规范一些,一般不会出错
select name from syscolumns where id=object_id('表名')--查出来哪个表的列名
select name from sysobjects where xtype= 'U '--查出来的是表名
select name from sysobjects where xtype= 'P '--存储过程


本文参考链接:https://www.cnblogs.com/zhangwei99com/p/7249432.html
标签:数据库
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

关注我们

一个IT知识分享的公众号