Sunday 20 November 2016

SQL Views

SQL Views

- Views are virtual tables that are compiled at run time. The data associated with views are not physically stored in the view, but it is stored in the base tables of the view. A view can be made over one or more database tables. 

- Generally we put those columns in view that we need to retrieve/query again and again. Once you have created the view, you can query view like as table. 

- We can make index, trigger on view.


- In Sql Server we make views for security purpose since it restricts the user to view some columns/fields of the table(s).

- Views show only those columns that are present in the query which is used to make view.One more advantage of Views is, data abstraction since the end user is not aware of all the data present in database table.

Syntax for View



Types of Views

In Sql Server we have two types of views.

01. System Defined Views


02. User Defined Views  

Let's take a look at User Defined views.

User Defined Views  

These types of view are defined by users. We have two types of user defined views.

- Simple Views (When we create a view on a single table, it is called simple view.)
-Complex Views(When we create a view on more than one table, it is called complex view.)

Example of Simple View







In simple view we can insert, update, delete data. We can only insert data in simple view if we have primary key and all not null fields in the view.






Summary

In this article I try to explain the view in sql server with example. I hope after reading this article you understood what SQL VIEW is. I would like to have feedback from my blog readers. Please post your feedback, question, or comments about this article.

Share with your friends! Thanks.......!


   

No comments: