Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
1.4 kB
9
Indexable
Never
20/02/2024:
-----------------------------------------------------------------------------------------------------------
Views:-
view is a virtual table base on resultset of the sql statement.
view contain row and columns.
syntax:-

create view view_name as
select columns from table_name


use third;
select * from customer;

create view custview as 
select * from customer;

select * from custview;

for create or update
create or replace view custview as 
select cust_id,cust_name from customer;

create view custdetails as 
select cust_name,city from customer where age=22;
==================================================================================================================

create view from multiple tables:-

syntax: create view view_name as
select table1.column1,table1.column2 ....,table2.column.....
from table1,table2;

create view custordview as
select c.cust_id,c.cust_name,o.item,o.price 
from customer c ,order1 o
where c.cust_id=o.cust_id;
select * from custordview


create view custordview1 as
select c.cust_id,c.cust_name,u.user_name
from customer c ,user u
where c.cust_id=u.user_id
select * from custordview1


===========================================================================================================

Drop the view
============
syntax:-
drop view view_name;

drop view custordview1
Leave a Comment