ORACLE Fundamental - SQL 1 أ آاروأ: Mustafa
ORACLE Fundamental - SQL 1 أ آاروأ: Mustafa
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. 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.
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
values
(&ID,'&&first_name','&&last_name',substr('&first_name',0,1)||substr('&last_name',0,7),&salary)
COMMIT;
11.Change the salary to $1,000 for all employees who have a salary less than $900.
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
3- select *
From employee;
COMMIT;
13.Delete Betty Dancs from the MY_EMPLOYEE table.
. f2ت وbJ @ ا4 آc! F^، اول4.. /ف اfG3 FO: 15&14 &13 *ال+ ا
where last_name='Betty';--
Commit;
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.
. فfG اtT @ اWG اBT "ع3 R وذj@T @ ا-hv ا% ءYة دون إ.ف اfG ا% ءY إ: ً 3را
. ض اول3 Rف وذfG ا% ;" ا@ا% 3 J ا/0 و"د ا4 !آ: ً +4
Savepoint created.
4 rows deleted.
3-SQL> select *
from my_employee;
no rows selected.
Rollback complete.
5-SQL> select *
from my_employee
where id=5;
6- SQL> commit ;
Commit complete.