What is a View ?
What is a View ?
• A VIEW in SQL Server is like a virtual table that contains data from one or multiple tables.
• It does not hold any data and does not exist physically in the database.
• Similar to a SQL table, the view name should be unique in a database.
• It contains a set of predefined SQL queries to fetch data from the database..
• It can contain database tables from single or multiple databases as well.
• A VIEW does not require any storage in a database because it does not exist physically.
View definition contd..
How to create a View
• CREATE VIEW Name AS
Select column1, Column2...Column N From tables
Where conditions;
• CREATE VIEW EmployeeRecords
AS
SELECT Person.Person.Title, Person.Person.FirstName, Person.Person.LastName,
Person.PersonPhone.PhoneNumber, Person.PhoneNumberType.Name
FROM Person.Person INNER JOIN
Person.PersonPhone ON Person.Person.BusinessEntityID = Person.PersonPhone.BusinessEntityID INNER JOIN
Person.PhoneNumberType ON Person.PersonPhone.PhoneNumberTypeID = Person.PhoneNumberType.PhoneNumber
TypeID
WHERE (Person.Person.Title = N'Mr.')