0% found this document useful (0 votes)
118 views4 pages

ORACLE Fundamental - SQL 1 أ آاروأ: Mohamed - Suez

1. The staff in the HR department wants a view called EMPLOYEES_VU that displays employee numbers, names, and department numbers from the EMPLOYEES table with the name heading changed to EMPLOYEE. 2. A view called DEPT50 was created to allow department 50 access to employee data with columns labeled EMPNO, EMPLOYEE, and DEPTNO and prevents reassignment of employees to other departments. 3. Various objects were created including a sequence named DEPT_ID_SEQ to generate primary keys for the DEPT table, a script to insert rows into the DEPT table using the sequence, a non-unique index on the DEPT_ID column, and a

Uploaded by

user
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)
118 views4 pages

ORACLE Fundamental - SQL 1 أ آاروأ: Mohamed - Suez

1. The staff in the HR department wants a view called EMPLOYEES_VU that displays employee numbers, names, and department numbers from the EMPLOYEES table with the name heading changed to EMPLOYEE. 2. A view called DEPT50 was created to allow department 50 access to employee data with columns labeled EMPNO, EMPLOYEE, and DEPTNO and prevents reassignment of employees to other departments. 3. Various objects were created including a sequence named DEPT_ID_SEQ to generate primary keys for the DEPT table, a script to insert rows into the DEPT table using the sequence, a non-unique index on the DEPT_ID column, and a

Uploaded by

user
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/ 4

2010

ORACLE Fundamental_ SQL 1 ‫ أ أوراآ‬

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

as select employee_id ,last_name employee,department_id

from employees;

2. Confirm that the view works. Display the contents of the EMPLOYEES_VU view.

. 4/6 => !(+‫ ا‬view ‫;آ أن اـ‬1 ‫وز‬- :2 ‫ اال‬


select *

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.

create or replace view dept50 ‫(ض‬VIEW ‫وز‬- :4 ‫ اال‬

as select employee_id empno,last_name employee,department_id . 50 ‫دارة‬3‫  ا‬#


deptno

from employees

where department_id=50;
5. Display the structure and contents of the DEPT50 view.

.VIEW‫ت ال‬%‫) و‬/F‫وز (ض ا&ء اا‬- : 5 ‫ اال‬

desc dept50;===================

select *

from dept50;

6. Test your view. A>empt to reassign Matos to department 80.

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.

.‫ ال‬I‫ت ا!"د‬%& Sequ !( ‫وز‬- : 7 ‫ اال‬


create sequence dept_id_seq

increment by 10

start with 200

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.

. ‫م‬5‫ر‬J‫ ا‬# # .‫دارة ا‬3‫ول ا‬. GK% ‫وز‬- : 8 ‫ اال‬


1-insert into dept

values(dept_id_seq.nextval,'Education');

2-insert into dept

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) ;

10. Create a synonym for your EMPLOYEES table. Call it EMP.

create synonym emp


.  !‫ول ا‬.  46‫وز ا‬- ‫ ه‬: 10 ‫ اال‬
for employees ;

You might also like