When to use database views and when not?

后端 未结 8 969
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 19:31

This question is about database views, not materialized-views.

Pros:

  • Query simplification.
  • Avoid repeat the same joins on mul
8条回答
  •  失恋的感觉
    2020-12-13 19:46

    I used to use them all the time, now rarely. However, I do all my data access thru stored procedures so the usefulness of a view is somewhat less since the SP can hide the complexity of the join where needed.

    I'd still consider using a view if a had a particularly complicated joined of many tables, from which I needed to then build many SP's on top of, but to be honest, I can't think of any I have in production right now.

    The other scenario would I would use one would be where my users have access to the database for generating their own reports, and I wanted to hide the underlying complexity for them.

提交回复
热议问题