Você está na página 1de 2

Aldo Francisco Resendiz Hernandez

1. Create a view called EMP_VU based on the employee number, employee name, and
department number from the EMP table. Change de heading for the employee name
to EMPLOYEE.
create view emp_vu
as select empno, ename EMPLOYEE, deptno
from emp;

2. Display de contents of the EMP_VU view.


select *
from emp_vu;

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

4. Using your view EMP_VU, enter a query to display all employee names and
department numbers.
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(LLEVA CONSTRAINT).
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.


describe dept20
select *
from dept20;

7. Attempt to reassign Smith to department 30.


update dept20 set DEPARTMENT_ID=30
where EMPLOYEE='Smith';
Aldo Francisco Resendiz Hernandez

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 or replace view salary_vu
as select e.ename, d.dname, e.sal, s.grade
from emp e, dept d, salgrade s
where e.deptno=d.deptno and e.sal
between s.losal and s.hisal;

Você também pode gostar