Why is SELECT * considered harmful?

后端 未结 15 1503
野的像风
野的像风 2020-11-21 04:12

Why is SELECT * bad practice? Wouldn\'t it mean less code to change if you added a new column you wanted?

I understand that SELECT COUNT(*)

15条回答
  •  庸人自扰
    2020-11-21 04:41

    Think of it as reducing the coupling between the app and the database.

    To summarize the 'code smell' aspect:
    SELECT * creates a dynamic dependency between the app and the schema. Restricting its use is one way of making the dependency more defined, otherwise a change to the database has a greater likelihood of crashing your application.

提交回复
热议问题