Why is using ‘*’ to build a view bad?

I don’t think there’s much in software that is “just bad”, but there’s plenty of stuff that is misused in bad ways 🙂

The example you give is a reason why * might not give you what you expect, and I think there are others. For example, if the underlying tables change, maybe columns are added or removed, a view that uses * will continue to be valid, but might break any applications that use it. If your view had named the columns explicitly then there was more chance that someone would spot the problem when making the schema change.

On the other hand, you might actually want your view to blithely
accept all changes to the underlying tables, in which case a * would
be just what you want.

Update: I don’t know if the OP had a specific database vendor in mind, but it is now clear that my last remark does not hold true for all types. I am indebted to user12861 and Jonny Leeds for pointing this out, and sorry it’s taken over 6 years for me to edit my answer.

Leave a Comment