ORACLE Fundamental - SQL 1 أ آاروأ: Mohamed - Suez
ORACLE Fundamental - SQL 1 أ آاروأ: Mohamed - Suez
Mohamed_Suez
إهاء إWWW.ARAB
/OUG/HARDWARE/TEAM2000
3/21/2010
LES 10 Creating Other Schema
Pracce 10
Part 1
1. The staff in the HR department wants 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.
ول. ا# VIEW "ول ا! ون رؤ# ت%&*) (' ا+ وزة- HR ه ل ان إدارة ال: 1 اال
.دارة3 ا45 ور45 وا467) ا/- ى12
create or replace view employee_vu
from employees;
2. Confirm that the view works. Display the contents of the EMPLOYEES_VU view.
from employee_vu ;
3. Using your EMPLOYEES_VU view, write a query for the HR department to display all employee names
and department numbers.
ال# 4?+م إدار5!ء ا! وأر6 اB/C مD(16وز إ- :3 اال
.VIEW
select employee,department_id
from employee_vu ;
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.
from employees
where department_id=50;
5. Display the structure and contents of the DEPT50 view.
desc dept50;===================
select *
from dept50;
update dept50 .VIEWل80 45دارة ر3 H2 وDEPT50 ال# G !وز ا- :6 اال
set deptno=80
Where employee='Matos'
-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.
increment by 10
maxvalue 1000;
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.
values(dept_id_seq.nextval,'Education');
values(dept_id_seq.nextval,'Administration');
COMMIT;
9. Create a nonunique index on the DEPT_ID column in the DEPT table.
. دارات3ول ا. دارة3 ا45!د ر- )/- )M/+ N وز (! ?س- : 9 اال
create index dept_id_index
on dept (dept_id) ;