Why is SELECT * considered harmful?

后端 未结 15 1453
野的像风
野的像风 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:54

    Generally you have to fit the results of your SELECT * ... into data structures of various types. Without specifying which order the results are arriving in, it can be tricky to line everything up properly (and more obscure fields are much easier to miss).

    This way you can add fields to your tables (even in the middle of them) for various reasons without breaking sql access code all over the application.

提交回复
热议问题