SQL Views:-
In this post we will be learning about SQL Views.
Views:
A view is basically a predefined query on one or more tables. Retrieving
information
from the view is done in the same manner as retrieving from the table.
Creating
a View: by using the create view statement we can create a view.
SQL Views |
Syntax:
Create [Or Replace]
View
view_name
[(allias_name[,allias_name….])]
AS
subquery
[WITH
{CHECK OPTION | READ ONLY} CONSTRAINT
Constraint_name];
Ex:
SQL> Create view medha_0016_view AS
Select
ename, eno, address from
Chaitu_0016;
View
Created.
Performing
an Insert using a View: we can also perform DML operations using the
views.
Given below is the example for that.
Ex:
SQL> Insert into medha_0016_view(
Ename,
eno, address) Values (CHAITU, 0016, HYD);
1
Row Created.
Modifying
a View: we can modify the view using the REPLACE. If there any view
existing
with that name then it was modified with the current one.
Ex:
SQL> Create or Replace
view
medha_0016_view
AS
Select
a.ename, a.eno, a.address, b.city from
Chaitu_0016
a, chaitu_0011 b
Where
a.eno = b.eno;
Dropping
a View: when want to drop the view we use this statement. Only the view
will
be dropped from the database the table was not effected.
Ex:
SQL> Drop view chaitu_0016_view;
In next post we will be learning SQL Sequence, So keep learning and start sharing :) Happy Blogging!!
In next post we will be learning SQL Sequence, So keep learning and start sharing :) Happy Blogging!!