What is the reason not to use select *?

后端 未结 20 2779
独厮守ぢ
独厮守ぢ 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:11

    Generally bad to use 'select *' inside of views because you will be forced to recompile the view in the event of a table column change. Changing the underlying table columns of a view you will get an error for non-existant columns until you go back and recompile.

    0 讨论(0)
  • 2020-11-21 08:12

    To answer you question directly: Do not use "SELECT *" when it makes your code more fragle to changes to the underlying tables. Your code should break only when a change is made to the table that directly affects requirments of your program.

    Your application should take advantage of the abstraction layer that Relational access provides.

    0 讨论(0)
提交回复
热议问题