0% found this document useful (0 votes)
37 views5 pages

Taller 4-KATHERN ROJAS PDF

1. The document describes creating several views from database tables including EMP_VU, DEPT20, and SALARY_VU. 2. EMP_VU displays employee number, name, and department number. DEPT20 only includes employees from department 20 and prevents reassigning employees. 3. SALARY_VU joins tables to display employee name, department name, salary, and grade for all employees.

Uploaded by

briggyd rojas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views5 pages

Taller 4-KATHERN ROJAS PDF

1. The document describes creating several views from database tables including EMP_VU, DEPT20, and SALARY_VU. 2. EMP_VU displays employee number, name, and department number. DEPT20 only includes employees from department 20 and prevents reassigning employees. 3. SALARY_VU joins tables to display employee name, department name, salary, and grade for all employees.

Uploaded by

briggyd rojas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Practice 4

1. Create a view called EMP_VU based on the employee number, employee name, and
department number from the EMP table. Change the heading for the employee name to
EMPLOYEE.
1. CREATE VIEW emp_vu AS
SELECT empno, ename EMPLOYEE, deptno from emp;

2. Display the contents of the EMP_VU view.

RTA: select *from emp_vu;


3. Select the view name and text from the data dictionary USER_VIEWS.

RTA: SELECT view_name, text


FROM user_views;

4. Using your view EMP_VU, enter a query to display all employee names and department
numbers.
RTA: create or replace view emp_vu
as select ename EMPLOYEE, deptno DEPTNO
from emp;

5. Create a view named DEPT20 that contains the employee number, employee name, and
department number for all employees in department 20. Label the view column
EMPLOYEE_ID, EMPLOYEE, and DEPARTMENT_ID. Do not allow an employee to be
reassigned to another department through the view.
RTA create or replace view dept20
as select empno EMPLOYEE_ID, ename EMPLOYEE, deptno
DEPARTMENT_ID
from emp
where deptno=20
with check option;

6. Display the structure and contents of the DEPT20 view.


RTA: 1. describe dept20
2. select *from dept20;

7. Attempt to reassign Smith to department 30.

RTA: update dept20


SET DEPARTMENT_ID=30
where EMPLOYEE='smith';

8. Create a view called SALARY_VU based on the employee name, department name, salary,
and salary grade for all employees. Label the columns Employee, Department, Salary, and
Grade, respectively.
CREATE VIEW salary_vu AS
SELECT ename employee, dname department,
sal salary, grade
FROM emp e, dept d, salgrade s
WHERE e.deptno = d.deptno
AND e.sal between s.losal and s.hisal;

You might also like