When to use a View instead of a Table?

前端 未结 8 1252
没有蜡笔的小新
没有蜡笔的小新 2020-12-04 07:02

When should a View actually be used over an actual Table? What gains should I expect this to produce?

Overall, what are the advantages of using a view over a table?

8条回答
  •  感情败类
    2020-12-04 07:31

    According to Wikipedia,

    Views can provide many advantages over tables:

    • Views can represent a subset of the data contained in a table.
    • Views can limit the degree of exposure of the underlying tables to the outer world: a given user may have permission to query the view, while denied access to the rest of the base table.

    • Views can join and simplify multiple tables into a single virtual table.

    • Views can act as aggregated tables, where the database engine aggregates data (sum, average, etc.) and presents the calculated results as part of the data.

    • Views can hide the complexity of data. For example, a view could appear as Sales2000 or Sales2001, transparently partitioning the actual underlying table.

    • Views take very little space to store; the database contains only the definition of a view, not a copy of all the data that it presents.

    • Views can provide extra security, depending on the SQL engine used.

提交回复
热议问题