
-- Creating a view definition 
create view custrep
as
select customername as CName, firstname as RFName, lastname as RepLname
from customer c, rep r
where c. repnum = r.repnum;

-- query using a view
select CName
From custrep
Where RFName = 'Juan';

-- The DBMS actually replaces the view name with its definition
-- and then the execute the query as below:
select CName
From (select customername as CName, firstname as RFName, lastname as RepLname
	  from customer c, rep r
	  where c. repnum = r.repnum) as temp
Where RFName = 'Juan';

-- Removing a view definition
drop view custrep


