What is the reason not to use select *?

后端 未结 20 3134
独厮守ぢ
独厮守ぢ 2020-11-21 07:14

I\'ve seen a number of people claim that you should specifically name each column you want in your select query.

Assuming I\'m going to use all of the columns anyway

20条回答
  •  别那么骄傲
    2020-11-21 08:03

    I understand where you're going regarding premature optimization, but that really only goes to a point. The intent is to avoid unnecessary optimization in the beginning. Are your tables unindexed? Would you use nvarchar(4000) to store a zip code?

    As others have pointed out, there are other positives to specifying each column you intend to use in the query (such as maintainability).

提交回复
热议问题