Вы находитесь на странице: 1из 3

Practice 10

Part 1
1. The staff in the HR department want to hide some of the data in the EMPLOYEES table.
They want a view called EMPLOYEES_VU based on the employee numbers, employee
names, and department numbers from the EMPLOYEES table. They want the heading
for the employee name to be EMPLOYEE.
2. Confirm that the view works. Display the contents of the EMPLOYEES_VU view.

3. Using your EMPLOYEES_VU view, write a query for the HR department to display all
employee names and department numbers.

Oracle Database 10g: SQL Fundamentals I 10 - 42


Practice 10 (continued)
4. Department 50 needs access to its employee data. Create a view named DEPT50 that
contains the employee numbers, employee last names, and department numbers for all
employees in department 50. You have been asked to label the view columns
EMPNO, EMPLOYEE, and DEPTNO. For security purposes, do not allow an employee to be
reassigned to another department through the view.
5. Display the structure and contents of the DEPT50 view.

6. Test your view. Attempt to reassign Matos to department 80.

Oracle Database 10g: SQL Fundamentals I 10 - 43


Practice 10 (continued)
Part 2
7. You need a sequence that can be used with the primary key column of the DEPT table. The
sequence should start at 200 and have a maximum value of 1,000. Have your sequence
increment by 10. Name the sequence DEPT_ID_SEQ.
8. To test your sequence, write a script to insert two rows in the DEPT table. Name your
script lab_10_08.sql. Be sure to use the sequence that you created for the ID column.
Add two departments: Education and Administration. Confirm your additions. Run the
commands in your script.
9. Create a nonunique index on the NAME column in the DEPT table.
10. Create a synonym for your EMPLOYEES table. Call it EMP.

Oracle Database 10g: SQL Fundamentals I 10 - 44

Вам также может понравиться