What is the purpose of views in SQL? [duplicate]
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
精彩评论