0% found this document useful (0 votes)
85 views5 pages

ORACLE Fundamental - SQL 1 أ آاروأ: Mustafa

The document provides instructions for performing data manipulation operations on the MY_EMPLOYEE table including inserting, updating, deleting, and controlling transactions. The tasks include populating the table with sample data, updating employee records, deleting a record, using savepoints to rollback a DELETE, and committing the transactions.

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)
85 views5 pages

ORACLE Fundamental - SQL 1 أ آاروأ: Mustafa

The document provides instructions for performing data manipulation operations on the MY_EMPLOYEE table including inserting, updating, deleting, and controlling transactions. The tasks include populating the table with sample data, updating employee records, deleting a record, using savepoints to rollback a DELETE, and committing the transactions.

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/ 5

2010

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

Mustafa
‫ إهاء إ‬WWW.ARAB
/OUG/HARDWARE/TEAM2000
3/21/2010
LES 08 Manipulating Data

Practice 8

The HR department wants you to create SQL statements to insert, update, and delete employee data.
As a prototype, you use the MY_EMPLOYEE table, prior to giving the statements to the HR
department.
Insert data into the MY_EMPLOYEE table.

1. Run the statement in the lab_08_01.sql script to build the MY_EMPLOYEE table to be used for the lab.

2. Describe the structure of the MY_EMPLOYEE table to identify the column names.

. ‫ء اول و" ! ض اء اا ول ا‬#! "‫وز‬% :2& 1‫*ال‬+‫ ا‬
DESC my_employee

3.Create an INSERT statement to add the first row of data to the MY_EMPLOYEE table from the
following sample data. Do not list the columns in the INSERT clause. Do not enter all rows yet.
ID LAST_NAME FIRST_NAME USERID SALARY
‫ول ا‬- ‫ول‬.‫ ا‬/0‫ت ا‬23 ! " ‫وز‬% :3 ‫*ال‬+‫ ا‬
1 Patel Ralph rpatel 895
. - 7%.‫ اول دون ذآ أء ا‬-4 ‫ زى‬/6 ‫ت اول‬23‫و‬
2 Dancs Betty bdancs 860
Insert into my_ employee
3 Biri Ben bbiri 1100

4 Newman Chad cnewman 750


Values

5 Ropeburn Audrey aropebur 1550


(1,’Patel’,’Ralph’,’rpatel’,895);

4. Populate the MY_EMPLOYEE table with the second row of sample data from the preceding list. This
time, list the columns explicitly in the INSERT clause.

5. Confirm your addi3on to the table.

Insert into my_ employee ‫; ذآ أء‬4 3 ‫ـ‬- ‫= ا ا‬2 ‫وز‬% : 5&4 ‫*ال‬+‫ ا‬
(ID,Last_name,First_name,Userid,Salary)
Values .3،4 @‫ ا‬AB@ "‫و‬، 7%.‫ا‬
(1,’Patel’,’Ralph’,’rpatel’,895);
-------------------------
Commit ;
6.Write an insert statement in a dynamic reusable script file named loademp.sql to load rows into
the MY_EMPLOYEE table. Concatenate the first letter of the first name and the first seven characters
of the last name to produce the user ID. Save this script to a file named lab_08_06.sql.

‫وف‬7 ‫ول واول‬.‫ ا‬F.‫ ا‬4 ‫ول‬.‫ف ا‬G‫ ا‬H4‫; د‬4 ‫ "ول ا‬- /6   I4J‫ " إدل د‬L@‫ اآ‬:8&7&6 ‫*ال‬+‫ ا‬
. ‫ ا‬3!‫ و‬WG‫ن ا‬BJ 4@‫; وا‬3+‫ || وا‬H4‫; ودا ا‬BT‫\دام اا ا‬P@Q3 R‫ ازر وذ‬FO‫   ر‬.‫ ا‬F.‫ ا‬4
insert into my_employee

(id ,last_name,first_name,userid ,salary )

values
(&ID,'&&first_name','&&last_name',substr('&first_name',0,1)||substr('&last_name',0,7),&salary)

.‫ف‬0‫ ا‬R! ‫ب إدل‬B‫ا‬

COMMIT;

9.Make the data addi3ons permanent.

Update and delete data in the MY_EMPLOYEE table.

10.Change the last name of employee 3 to Drexler.

11.Change the salary to $1,000 for all employees who have a salary less than $900.

12.Verify your changes to the table.

1- SQL> update .3 FO‫ ر‬/ .‫ ا‬F.‫ ا‬Y@3 ‫ول‬- J @‫ ا‬LBJ : [ً ‫ أو‬:12-9 ‫*ال‬+‫ ا‬
my_employee
.1000 ‫إ‬900 4 O‫ أ‬F‫  ه‬L!‫ ا‬Y! : ً 2^
set last_name='Drelex'
. dT- ‫آ‬c! e"‫ر‬.‫= ا‬3 ‫ه‬f2 I4‫ اول و‬- ‫ت‬bJ @‫ ا‬4 ‫آ‬c! : ً a^
where id=3;

1row updated.

2- update my_employee

set salary=1000

where salary <900;

3- select *

From employee;

COMMIT;
13.Delete Betty Dancs from the MY_EMPLOYEE table.

14.Confirm your changes to the table.

15. Commit all pending changes.

. f2‫ت و‬bJ @‫ ا‬4 ‫آ‬c! F^، ‫ اول‬4.. /‫ف ا‬fG3 FO: 15&14 &13 ‫*ال‬+‫ ا‬

delete from my_employee

where last_name='Betty';--

Commit;

Control data transaction to the MY_EMPLOYEE table.

16. Populate the table with the last row of sample data by using the statements in the script
that you created in step 6. Run the statements in the script.

17.Confirm your addition to the table.

‫ام ا‬g@Q3 .‫ ا‬/0‫ ا‬-h‫وز إ‬% :17&16 ‫*ال‬+‫ ا‬


Select *… 3 ‫آ‬c@‫وز ا‬% ‫ وآن‬،ً i j...6 ‫*ال‬+‫ا‬

18. Mark an intermediate point in the processing of the transaction.


19. Empty the entire table.
20. Confirm that the table is empty.
21. Discard the most recent DELETE operation without discarding the earlier INSERT operation.
22. Confirm that the new row is still intact.
23. Make the data addition permanent.

: ‫ب‬B‫ ا‬:23-18 ‫*ال‬+‫ ا‬

. Savepoint W BT2 % :[ً ‫أو‬

. ‫ت‬2‫ ا‬4 r!J@G4 4 ‫غ اول‬- : ً 2^

. ‫ت دا اول‬23 ‫م و"د‬% 4 ‫آ‬c! : ً a^

. ‫ف‬fG‫ ا‬tT @‫ ا‬WG‫ ا‬BT ‫"ع‬3 R‫ وذ‬j@T @‫ ا‬-hv‫ ا‬% ‫ء‬Y‫ة دون إ‬.‫ف ا‬fG‫ ا‬% ‫ء‬Y‫ إ‬: ً 3‫را‬

. ‫ ض اول‬3 R‫ف وذ‬fG‫ ا‬% ;"‫ ا@ا‬%  3 J‫ ا‬/0‫ و"د ا‬4 ‫ !آ‬: ً +4

. r@3^‫ و‬x‫\ دا‬F‫ت ا‬2‫ إ"  ا‬: ً ‫د‬


1-SQL> savepoint sv_emp_1;

Savepoint created.

2-SQL> delete my_employee

4 rows deleted.

3-SQL> select *

from my_employee;

no rows selected.

4-SQL> rollback to sv_emp_1;

Rollback complete.

5-SQL> select *

from my_employee

where id=5;

6- SQL> commit ;

Commit complete.

You might also like