U2T5 Views in SQL
U2T5 Views in SQL
Table-2: department
Deptid Dept_name
1 HR
2 IT
This view will show employee names along with their department names.
Output
Name Dept_name
Alice HR
Bob IT
Charlie HR
Operations on View
3. Dropping a view
To remove a view , we can use the DROP VIEW command.
Advantage of Views:
Data abstraction: Hides complexity from the end-user.
Reusability: Saves time by reusing complex queries
Security: Restricts access to sensitive data by only showing selected columns or rows.
Example:
In above table is consider as student table and there is three different columns
( Regno,Name,Mark)
For that one table there are total 3-views
1st-view for the Teacher, Teacher can view complete table like (Regno ,Name , Marks).
2nd view for the Student , Student can view only (Regno , Name) and Makrs columns hides from the
Students
3rd view for the Office staff , office staff can view only(Name) and Regno,Marks hide from the office
staff
So there is only one table and there are total 3-views of that particular users. So this views are
called as “virtual Table”.
You can view the particular table as per the restriction ,as per the add authorized person or as per
the requirement so this is called as view.
Limitation
Views do not store data themselves; they simply store the query.
Some views, especially those with joins or aggregations, might not be directly updateable.
VIEW TABLE
A database object that allows generating a logical A database object or an entity that stores the data
subset of data from one or more tables of a database