Why is using '*' to build a view bad?

后端 未结 14 2216
执念已碎
执念已碎 2020-11-27 07:02

Why is using \'*\' to build a view bad ?

Suppose that you have a complex join and all fields may be used somewhere.

Then you just have to chose fields needed

14条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-27 07:55

    Once upon a time, I created a view against a table in another database (on the same server) with

    Select * From dbname..tablename
    

    Then one day, a column was added to the targetted table. The view started returning totally incorrect results until it was redeployed.


    Totally incorrect : no rows.

    This was on Sql Server 2000.

    I speculate that this is because of syscolumns values that the view had captured, even though I used *.

提交回复
热议问题