SQL中查询表中包含的字段名称⽬录
⼀、SQL SERVER
1、查看所有表名:
select name from sysobjects where type='U'
2、查询表的所有字段名:
Select name from syscolumns Where ID=OBJECT_ID('表名')
select * from information_schema.tables
select * from information_schema.views
select * from lumns
3、查询某个表的列名称、说明、备注、类型等
------sqlserver 查询某个表的列名称、说明、备注、类型等
SELECT
表名      = case lorder=1 then d.name else '' end,
sql中select是什么意思
表说明    = case lorder=1 then isnull(f.value,'') else '' end,
字段序号  = a.colorder,
字段名    = a.name,
标识      = case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end,
主键      = case when exists(SELECT 1 FROM sysobjects where xtype='PK' and parent_obj=a.id and name in (
SELECT name FROM sysindexes WHERE indid in( SELECT indid FROM sysindexkeys WHERE id = a.id AND lid))) then '√' else '' end,类型      = b.name,
占⽤字节数 = a.length,
长度      = COLUMNPROPERTY(a.id,a.name,'PRECISION'),
⼩数位数  = isnull(COLUMNPROPERTY(a.id,a.name,'Scale'),0),
允许空    = case when a.isnullable=1 then '√'else '' end,
默认值    = ,''),
字段说明  = isnull(g.[value],'')
FROM
syscolumns a
left join
systypes b
on
a.xusertype=
b.xusertype
inner join
sysobjects d
on
a.id=d.id  pe='U' and  d.name<>'dtproperties'
left join
syscomments e
on
a.cdefault=e.id
left join
on
a.id=G.major_id lid=g.minor_id
left join
on
d.id=f.major_id and f.minor_id=0
where
d.name='Sys_User'    --如果只查询指定表,加上此where条件,tablename是要查询的表名;去除where条件查询所有的表信息
order by
a.lorder
⼆、MySql
1、查询表的所有字段名:
select *
from lumns
where table_name='table_name'
and table_schema='table_schema'
ORDER BY ORDINAL_POSITION
三、ACCESS
查看所有表名:
select name from MSysObjects where type=1 and flags=0
MSysObjects是系统对象,默认情况是隐藏的。通过⼯具、选项、视图、显⽰、系统对象可以使之显⽰出来。
四、Oracle
select cname from col where tname='ZW_YINGYEZ'
select column_name from user_tab_columns where table_name='ZW_YINGYEZ'
查询表字段数
select count(column_name) from user_tab_columns where table_name='表名';

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。