View:

1.Views are created from one or more than one tables.

2.Acting as a layer between user and table

3.Reducing the effort while writing queries to access multiple specific columns from many tables

4. Allowing us to hide some columns from the user because of security reasons.

5.View doesn’t contain any data.

6. We can do DML statement (Insert, Delete, Update) on view but it must be satisfy some conditions.

Example:

USE tempdb;
GO
CREATE TABLE Table1(ID int,Name varchar(30));
GO
INSERT INTO Table1 VALUES(1,’Testing1′);
INSERT INTO Table1 VALUES(2,’Testing32′);
GO
–> Create a view
CREATE VIEW View1 AS SELECT * FROM Table1;
GO
SELECT * FROM View1;
GO
–> Insert data into View1
INSERT INTO View1 VALUES(3,’Testing3′);

GO
–> Select data from Table1
SELECT * FROM Table1;
GO
–> Update View1
UPDATE View1
SET Name = ‘Testing’
WHERE ID =1;
GO
–>Select data from Table1
SELECT * FROM Table1;

Please reference link to understand view http://msdn.microsoft.com/en-us/library/ms187956.aspx

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s