何时使用View而不是Table? [英] When to use a View instead of a Table?
本文介绍了何时使用View而不是Table?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
实际上应该在实际的表上使用View吗?我应该期待什么收益?
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? Shouldn't I design the table in the way the view should look like in the first place?
推荐答案
哦有很多差异您将需要考虑
Oh there are many differences you will need to consider
供选择的视图:
- 视图提供了对表的抽象。您可以在视图中轻松添加/删除字段,而无需修改基础架构
- 视图可以轻松建模复杂的连接。
- 视图可以隐藏数据库特定你的东西例如。如果您需要使用Oracles SYS_CONTEXT功能或许多其他功能进行一些检查
- 您可以直接在视图上管理GRANTS,而不是实际的表。如果您知道某个用户只能访问视图,那么管理更容易。
- 视图可以帮助您提供向后兼容性。您可以更改基础模式,但视图可以隐藏某个客户端的这些事实。
- Views provide abstraction over tables. You can add/remove fields easily in a view without modifying your underlying schema
- Views can model complex joins easily.
- Views can hide database-specific stuff from you. E.g. if you need to do some checks using Oracles SYS_CONTEXT function or many other things
- You can easily manage your GRANTS directly on views, rather than the actual tables. It's easier to manage if you know a certain user may only access a view.
- Views can help you with backwards compatibility. You can change the underlying schema, but the views can hide those facts from a certain client.
插入/更新视图:
- 您可以直接在视图中使用Oracle的WITH CHECK OPTION子句等功能来处理视图的安全问题
缺点
- 你丢失关系的信息(主键,外键)
- 是否可以插入/更新视图是不明显的,因为该视图隐藏了它的底层连接
这篇关于何时使用View而不是Table?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文