written 2.2 years ago by |
Views in SQL : A view is nothing more than SQL statement that is stored in the database with an associate name.
A view is actually a composition of a table in the form of a predefined SQL query.
A view can be contain all rows of a table or selected rows from a table.
A view may be created from or more tables.
Creating view.
Syntax :
create view viewname as
{SQL select query}
example
consider a customer table as.
cust (id, name, email, city, state, phone)
create view cust_info as.
select id, name, email,
from cust.
This will show only little information about customer.
we can execute normal query OD view to view data.
eg. select * from cust_info
Uses of view :
Hiding some information from user.
Predefined queries to make writing other queries simple.
Implementation of view :
Views are implemented as temporary tables in database.
Updating a view :
As views are stored as temporary relations we can do insertion, deletion and updation.