当前位置:首页 » 编程语言 » sql显示表字段命令
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

sql显示表字段命令

发布时间: 2023-02-19 11:12:05

sql语句怎么查询表的字段属性名

看了看但不是太明白.随便说说.你的意思是说你用编号和表名来查询对吗?
就象楼上朋友说的那样
select * from student where 编号=1
这样就可以满足只知道编号和表名查询.但如果编号不固定的话你可以取控件中的值.比如:人为在TEXT1里输入编号.查询满足它的条件.在TEXT2中输入要查询的表名.
strwhere="select * from'" & trim(text2.text) & "'" & "where 编号=" & "'" & trim(text1.text) & "'"
我没在VB上试因为现在没这软件.好久没摸了你可以试下行不行.最后出来就是向上面一样的查询.

② 什么SQL语句可以列出表的字段名

SQL SERVER中的语句是

select name
from syscolumns
where id =object_id('表名')

把“表名”替换成实际的表名。

③ sql查询表中字段

select * from --主查询
(select namea=c.name from syscolumns c,sysobjects o where o.id=c.id and o.xtype='u' and o.name='tablea') a--A表中所有字段
full join --使用全连接
(select nameb=c.name from syscolumns c,sysobjects o where o.id=c.id and o.xtype='u' and o.name='tableb') b--B表中所有字段
on namea=nameb where namea is null or nameb is null--只保留不同的字段
查询结果是,两表不同的字段列出,两表均有的字段不列:
NAMEA,NAMEB
FIELD1 NULL
FIELD2 NULL
NULL FIELD3
NULL FIELD4

④ Sql数据库查询,如何实现只显示为某值的字段

实现只显示为某值的字段,可以通过行列转换实现。
以下是以sql server为例来说明:
select b.stu_name,
max(case a.subject when '语文' then a.grade else '' end) as 语文,
max(case a.subject when '数学' then a.grade else '' end) as 数学,
max(case a.subject when '英语' then a.grade else '' end) as 英语
from stu_grade a,stu_master b
where a.stu_no=b.stu_no
group by b.stu_name
数据库为oralce的话执行
select b.stu_name,
max(case a.subject when '语文' then to_char(a.grade) else '' end) as 语文,
max(case a.subject when '数学' then to_char(a.grade) else '' end) as 数学,
max(case a.subject when '英语' then to_char(a.grade) else '' end) as 英语
from stu_grade a,stu_master b
where a.stu_no=b.stu_no
group by b.stu_name

⑤ sql如何查询表中的字段

方法一:
select name from syscolumns where id = object_id('表名');

方法二:
sp_columns 表名

⑥ 如何用SQL语言检索表中的字段名

SQL SERVER

查看所有表名:
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

ACCESS

查看所有表名:
select name from MSysObjects where type=1 and flags=0

MSysObjects是系统对象,默认情况是隐藏的。通过工具、选项、视图、显示、系统对象可以使之显示出来。

⑦ SQL数据库某个表中的字段里显示出来,如何写成语句

select t.省份,t.城市,p.shixian as 地区
from(select a.省份,b.shixian as 城市,b.cid
from (select shixian as 省份,cid from tb where id=0) a
left join tb as b on a.cid=b.id
) t
left join tb as p on t.cid=p.id
;

⑧ SQL Server:用什么语句可以查看到一张表中的所有字段谢谢。

select * from syscolumns where id=object_id('数据表名')

⑨ 怎样用SQL查询一个表的所有字段

可以用一句sql语句查询解决,如要查test表中的所有字段及类型

Selectb.nameasTableName,C.nameASTYPEfromsyscolumnsa,sysobjectsb,systypesc
wherea.id=b.id
andb.type='U'
anda.xtype=c.xtype
andb.name='TEST';

结果截图:

⑩ 查询表中字段的sql语句怎么写

这次查询表中的字段名的目标是在写程序的时候需要写一点sql语句,但是表的字段太多了,如果一个一个去复制的话太慢了,而且有可能会复制漏了某个字段,所以利用自己数据库的知识,写了个sql语句直接生成字段名字符串,例如下面我要写一个select语句,需要生成表所有的字段:

declare @s varchar(1000)

select @s = isnull(@s+',', '') + [name] from syscolumns where id = object_id('相应表名')

select @s
获取字段名已经字段类型,类型长度

SELECT a.colid as ID,a.name as ColumnName,b.name as DataType,a.length
as Length FROM syscolumns a,systypes b WHERE a.id=
object_id('相应的表名') and a.xtype=b.xtype
and b.name <> 'sysname' order by a.colid