VIEWS: CREATE, DROP, MATERLIZED

35 programming challenges to help you master the fundamentals of DATABASE MANAGEMENT SYSTEM USING ORACLE.

1

Create a view to display employee name, salary, and department number from EMP table.

(VIEW – EMP TABLE)

2

Create a view to display employee name and department name by joining EMP and DEPT tables.

(VIEW – EMP + DEPT JOIN)

3

Create a view to display employees working in department 10.

(VIEW – FILTER CONDITION)

4

Create a view to display employee name, job, and annual salary (SAL * 12).

(VIEW – CALCULATED COLUMN)

5

Create a view to display department name and location from DEPT table.

(VIEW – DEPT TABLE)

6

Create a view to display employee name, department name, and location.

(VIEW – JOIN EMP & DEPT)

7

Create a view to display employees earning more than 3000.

(VIEW – CONDITION)

8

Create a view to display department-wise total salary using EMP table.

(VIEW – GROUP FUNCTION)

9

Create a view to display only managers (JOB = 'MANAGER').

(VIEW – FILTER)

10

Create a view with column aliases for employee name and salary.

(VIEW – ALIASING)

11

Create a view for employees in department 20 with WITH CHECK OPTION.

(WITH CHECK OPTION – EMP)

12

Insert a new employee into the above view with department 20.

(WITH CHECK OPTION – VALID INSERT)

13

Try inserting an employee with department 30 into the same view.

(WITH CHECK OPTION – INVALID INSERT)

14

Update department number through the view from 20 to 30. What happens?

(WITH CHECK OPTION – UPDATE RESTRICTION)

15

Create a view for employees with salary > 2000 and enforce condition using WITH CHECK OPTION.

(WITH CHECK OPTION – SALARY CONDITION)

16

Create a READ ONLY view to display employee details.

(READ ONLY VIEW – EMP)

17

Create a READ ONLY view to display employee name and department name.

(READ ONLY VIEW – JOIN EMP & DEPT)

18

Try updating salary through a READ ONLY view.

(READ ONLY VIEW – UPDATE RESTRICTION)

19

Try inserting a new employee through a READ ONLY view.

(READ ONLY VIEW – INSERT RESTRICTION)

20

Create a READ ONLY view for employees in department 10.

(READ ONLY VIEW – FILTER)

21

Create a materialized view to store employee name and salary from EMP table.

(MATERIALIZED VIEW – BASIC)

22

Create a materialized view to store employee name and department name using EMP and DEPT tables.

(MATERIALIZED VIEW – JOIN)

23

Create a materialized view with REFRESH COMPLETE for EMP table.

(MATERIALIZED VIEW – COMPLETE REFRESH)

24

Create a materialized view with REFRESH FAST (assume logs exist).

(MATERIALIZED VIEW – FAST REFRESH)

25

Create a materialized view with REFRESH ON COMMIT.

(MATERIALIZED VIEW – AUTO REFRESH)

26

Create a materialized view to store department-wise total salary.

(MATERIALIZED VIEW – GROUP BY)

27

Create a materialized view with BUILD IMMEDIATE option.

(MATERIALIZED VIEW – BUILD OPTION)

28

Create a materialized view with BUILD DEFERRED option.

(MATERIALIZED VIEW – BUILD OPTION)

29

Refresh a materialized view manually.

(MATERIALIZED VIEW – REFRESH COMMAND)

30

Drop a materialized view created on EMP table.

(MATERIALIZED VIEW – DROP)

31

Create a view joining EMP and DEPT and restrict it using WITH CHECK OPTION.

(VIEW + CHECK OPTION)

32

Create a READ ONLY view that shows employee name, department name, and salary.

(READ ONLY VIEW – JOIN)

33

Create a complex view to display department name and highest salary in each department.

(VIEW – AGGREGATE + JOIN)

34

Create a materialized view based on the above complex query.

(MATERIALIZED VIEW – ADVANCED)

35

Create a view that hides salary but shows employee name and department name.

(VIEW – SECURITY PURPOSE)