SQL中表中字段为数值型,查询条件中使用字符型与数值型查询效率上有区别吗?

2025-04-07 12:40:58
推荐回答(2个)
回答1:

这个跟效率无关了。。。。。select * from aa where 序号=1 为 数值型select * from aa where 序号='1' 为 字符型 当你的字段类型为 数值型的时候 你用两个可能都查得到但是如果你字段为 字符型 你用select * from aa where 序号=1 绝对查不到

回答2:

select syscolumns.name as 字段名,systypes.name as 类型,syscolumns.length as 长度 from syscolumns inner join systypes on syscolumns.xtype=systypes.xtype where id=object_id('你的表') 获得表中字段类型