What are the views in the database and why do we are use views in the Database?

Asked 14-Sep-2021
Viewed 765 times

0

What are the views in the database and why do we are use views in the Database?


1 Answer


0

Views in SQL Server database :

    Views are the virtual table that holds the data from one table or more tables. It is stored in database and does not contain any data itself. It is a set of queries that are applied to one or more table that store in the database as an object. Views are used for security purpose in database. Using a view we can apply restriction on accessing data specific row and column for specific user. View display the data that specified in the query. A view is created using a 'SELECT' statement.  Views are stored in the database as an object so it does not require additional storage. 

Types :

    Views are two types :

1- User Defined View.

2- System Defined View.

Create View Syntax-

create view view_name  as select column1,column2,... from table_name where condition; 

Delete View syntax -

Drop view view_name 

Using of Views in SQL Database:

 There are many reasons of using views in database which are as -

1- Improve security of database for accessing the data.

2- Views is used to restrict the user for accessing and viewing data from database.

3- View display the data that are specified in the query.

4- Views can hide the complexity of data of database. 

5- Views generally create by using SQL  SELECT statement. 

6- A View always show up to date data because the database engine recreate the view every time when a user fire a query.