Which is faster/best? SELECT * or SELECT column1, colum2, column3, etc

后端 未结 30 3070
清歌不尽
清歌不尽 2020-11-21 23:59

I\'ve heard that SELECT * is generally bad practice to use when writing SQL commands because it is more efficient to SELECT columns you specificall

30条回答
  •  心在旅途
    2020-11-22 00:44

    Lots of good reasons answered here so far, here's another one that hasn't been mentioned.

    Explicitly naming the columns will help you with maintenance down the road. At some point you're going to be making changes or troubleshooting, and find yourself asking "where the heck is that column used".

    If you've got the names listed explicitly, then finding every reference to that column -- through all your stored procedures, views, etc -- is simple. Just dump a CREATE script for your DB schema, and text search through it.

提交回复
热议问题