tags:

views:

181

answers:

2

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?

A: 
  • 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 to see the phone number column, but only certain employees to be able to access an employees 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 persons birth date, but you like to calculate this to determine their age.

Yada
A: 

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  
ChaosPandion