0% found this document useful (0 votes)
829 views3 pages

SQL Fundamentals - Practice 10

The document describes tasks for creating views and other database objects for an HR department. It includes: 1) Creating a view called EMPLOYEES_VU to hide some EMPLOYEES table data and rename an employee name column. 2) Creating a view called DEPT50 for department 50's employee data with security to prevent reassigning employees. 3) Creating a sequence called DEPT_ID_SEQ to generate primary keys for the DEPT table starting at 200, incrementing by 10, and having a maximum value of 1000.

Uploaded by

Abby AR
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
829 views3 pages

SQL Fundamentals - Practice 10

The document describes tasks for creating views and other database objects for an HR department. It includes: 1) Creating a view called EMPLOYEES_VU to hide some EMPLOYEES table data and rename an employee name column. 2) Creating a view called DEPT50 for department 50's employee data with security to prevent reassigning employees. 3) Creating a sequence called DEPT_ID_SEQ to generate primary keys for the DEPT table starting at 200, incrementing by 10, and having a maximum value of 1000.

Uploaded by

Abby AR
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 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

You might also like