In this article, I describe Views in SQL Server. This is a simple topic. I hope this article will help you just like my Windows Store articles. Please give me your valuable suggestions and feedback to improve my articles.

What is a View

Views are database objects which are like virtual tables that have no physical storage and contains data from one table or multiple tables. A View does not have any physical storage so they do not contain any data. When we update, insert or apply any operation over the View then these operations are applied to the table(s) on which the view was created.

Types Of View

System View

User Define View

User Defined Views are important so I describe only User Defined Views. They are of two types:

Simple View

Complex view

Simple View:

When a View is created on a single Table than it is called a Simple View. We can apply all operations on a Simple View that we can apply on a table.

First of all we create a table on which we create a view.

createtableemp(empIdint,empNamevarchar(15),empAddvarchar(15))Now insert data by the following code.

insertintoemp

select 1,'deepak','UA'unionall

select 2,'Middha','Punjab'unionall

select 3,'d','Delhi'unionall

select 4,'gourav','Noida'unionall

select 5,'deepakia','Laksar'unionall

select 6,'Deep','Haridwar'

Table:

Creation of a simple view:

createviewv1

as

select*fromemp

Operation on view:

See all the data of the view:

select*fromv1Output:

See the specific data of the view:

select*fromv1whereempId=4

Output:

Insertion:

insertintov1values(7,'raj','canada');

Output:

Updating:

updatev1setempAdd='usa'whereempId=7

Output:

deletion:

deletefromv1whereempId=7

Output:

Renaming:

execsp_rename'v1','v11'

Logic of the View:

execsp_helptextv1

Output:

Dropping the View:

dropviewv1

Encrypted View:

createviewv1

withencryption

as

select*fromemp

Complex view:

Views created on more than one table are called Complex View. We cannot perform all operations of a table on a Complex View.

In this app I described Views in SQL Server. I hope this article has helped you to understand this topic. Please share if you know more about this. Your feedback and constructive contributions are welcome.