Professional Documents
Culture Documents
Objectives:
The objective of this lab session is to know what is View, how to create,
update, delete the view.
By the end of this lab students will be able
To understand what is a view
To understand how a view is created/update/deleted.
Lab 10 VIEWS
OBJECTIVE:
COMMANDS EXECUTION
CREATION OF TABLE:
Database views are created using the CREATE VIEW statement. Views can be created from
a single table, multiple tables, or another view. To create a view, a user must have the
appropriate system privilege according to the specific implementation.
Create view
AS
SELECT EMP_ID, DEPT_ID
FROM EMP_DEPT
WHERE EMP_ID IS NOT NULL
WITH CHECK OPTION;
UPDATE EMP_NAME
SET EMP_ID = 35
WHERE EMP_NAME ='Ramesh';
Page 2 of 5
%
Enrollment Number: ____________________________
Task 1
Page 3 of 5
%
Enrollment Number: ____________________________
Write a query to create a view for those salesmen belongs to the city New York.
Write a query to create a view for all salesmen with columns salesman_id, name, and
city.
Write a query to find the salesmen of the city New York who achieved the commission more
than 13%.
Write a query to create a view to getting a count of how many customers we have at
each level of a grade
create view customer_count
as
select count (grade)
from customer10
Write a query to create a view to keeping track the number of customers ordering,
number of salesmen attached, average amount of orders and the total amount of orders
in a day.
Task 2
Write a query to create a view that shows for each order the salesman and customer
by name.
Page 4 of 5
%
Enrollment Number: ____________________________
as salesmanname
from customer10,salesman,orders
Write a query to create a view that finds the salesman who has the customer with the
highest order of a day.
Write a query to create a view that finds the salesman who has the customer with the
highest order at least 3 times on a day
Write a query to create a view that shows all of the customers who have the highest
grade.
Page 5 of 5