开发者

What is the purpose of views in SQL? [duplicate]

This question already has answers here: 开发者_JAVA百科 Closed 12 years ago.

Possible Duplicate:

What are views good for?

I'm trying to figure out what the purpose of views in an SQL database is?

Why, when and how would I create and use views?


  • Many different perspectives of the same table.

  • Can hide certain columns in a table. For example you may want to allow employees to see other employees' phone number column, but only certain employees to be able to access an employee's salary column!

  • Can provide huge time savings in writing queries by already having a group of frequently accessed tables joined together in a view.

  • Views allow you to use functions and manipulate data in ways that meet your requirements. For example, you store a person's birth date, but you like to calculate this to determine their age.


It can be used to simplify complex joins that you use repeatedly across your DB.

CREATE view [dbo].[V_MyComplexJoin] 
As    
    Select TableA.A, TableB.B
    From TableA
        Inner Join TableB On TableA.BID = TableB.ID  
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜