从表中选择*或从表中选择id,field1,field2,field3-最佳做法? [英] Select * from table OR select id,field1, field2, field3 from table - best practice?

查看:58
本文介绍了从表中选择*或从表中选择id,field1,field2,field3-最佳做法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我什么是更好的做法吗?对于选择查询,我应该返回全部还是所需的ID?

Could someone chime in as to whats a better practice? for select queries should I return all or the IDs that I require?

效率?可扩展性?等

谢谢

Env:SQL Server 2008,VS2008(VB)

Env: SQL Server 2008, VS2008 (VB)

推荐答案

使用table中的select col1,col2,col3,而不是table1中的select *.如此处和此处所述,它具有许多优点.

Use select col1, col2, col3 from table instead of select * from table1. This has numerous advantages, as mentioned here and here.

另请参阅: http://weblogs.sqlteam.com/jeffs/jeffs/archive/2007/07/26/60271.aspx

Select *之间是否有区别*并选择[列出每个列]

这篇关于从表中选择*或从表中选择id,field1,field2,field3-最佳做法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆