You are on page 1of 27

ORACLE LAB EXERCISES

A.RDBMS CONCEPTS: Lab Exercise No: 1 Exercise Objective s!: Exercise: 1) Draw an E-R diagram for the following application. a. A training institute conducts up to 6 courses. b. A course can have up to 3 students. c. A student can enroll for a particular course onl! once. "owever a student can enroll for an! number of courses. #he date of enrollment of the course is also maintained. d. A course is described b! its course-id$ title and duration$ course-id being the primar! %e!. e. A student is described b! stud-id$ name and address &house number$ street or area$ town$ dist $ cit! state). #he stud-id is the primar! %e!. f. #here is no student who has not ta%en an! course. #here are however courses for which there are no students. Reco""e#$e$ $%ratio#: 3 mins So&%tio# '%i$a#ce i( a))&icab&e!:NA Lab Exercise No: ' Exercise Objective s!: Exercise: Draw an E-R diagram for the following application. a. A compan! maintains details of its Emplo!ees li%e emp(d$ name$ date of birth) b. Each Emplo!ee wor%s for a single department. c. #here are two t!pes of emplo!ee- )ontract and *ermanent. )ontract emplo!ees wor% for a period of time and are given temporar! id. #he! are paid in per da! basis. *ermanent emplo!ees are paid ever! month and the! have permanent id. d. Department is identified b! dept(d$ name. e. Each department has one of the emplo!ees as manager. f. )ompan! also needs the details of all the Emplo!ee+s ,an% accounts. g. ,an% Account details are acct-umber$ #!pe of account$ -ame of the ,an% and ,ranch. Reco""e#$e$ $%ratio#: 3 mins So&%tio# '%i$a#ce i( a))&icab&e!:NA Lab Exercise No: 3 Exercise Objective s!: Exercise:

Draw an ER diagram for a bus compan! with following specifications. a. A )ountr! ,us )ompan! owns a number of busses. b. Each bus is allocated to a particular route$ although some routes ma! have several busses. c. Each route passes through a number of towns. d. /ne or more drivers are allocated to each stage of a route. e. A stage corresponds to a 0ourne! through some or all of the towns on a route. f. 1ome of the towns have a garage where busses are %ept and each of the busses are identified b! the registration number and can carr! different numbers of passengers$ since the vehicles var! in si2e and can be single or double-dec%ed. g. Each route is identified b! a route number and information is available on the average number of passengers carried per da! for each route. Reco""e#$e$ $%ratio#: 3 mins So&%tio# '%i$a#ce i( a))&icab&e!:NA

Lab Exercise No: 3 Exercise Objective s!: Exercise: Draw an ER diagram for application recording information about maga2ines$ writers$ and subscribers$ including. a. 4or each maga2ine$ its name$ its writers$ its editor$ and the cities to which it is delivered are to be maintained. b. 4or each writer$ their id$ name is to be maintained. &-ote. a writer can write for more than one maga2ine$ but can onl! edit$ at most$ one maga2ine.) c. 4or each subscriber$ their name$ favorite writers$ cit! or residence$ and what maga2ines the! receive are to be maintained. d. 4or all entities and relationships$ select and specif! %e!s. Reco""e#$e$ $%ratio#: 3 mins So&%tio# '%i$a#ce i( a))&icab&e!:NA Lab Exercise No: 5 Exercise Objective s!: Exercise: -ormali2e the given table to '-4 and 3-4. &15mins) "app! "ome 1uper mar%et deals with groceries$ household items$ stationar! products and gift items. #he! have announced a summer mela where$ for ever! customer who holds a membership with "app! "ome$ an! three items can be ta%en for free. #he total price of the three items should be e6ual to or below Rs.1 . #he! record details of these free products given to their member customers in a table as below.

Reco""e#$e$ $%ratio#: 3 mins So&%tio# '%i$a#ce i( a))&icab&e!:NA

Lab Exercise No: 6 Exercise Objective s!: Exercise: -ormali2e the given table ensuring no data loss and data redundanc! &15mins)

Reco""e#$e$ $%ratio#: 15 mins So&%tio# '%i$a#ce i( a))&icab&e!:NA Lab Exercise No: 7 Exercise Objective s!: Exercise: 8ood 9or% )ooperation is the )omputer *rogramming 1ervices industr! in DA::A1$ #;. (t has offices throughout -orth and 1outh (ndia. Emplo!ee fills in the following details at the time of 0oining . -ame$ *hone number$ "iredate$ 1alar!$ )ommission and Address. "e<1he is given a uni6ue (D. Emplo!ee is then allocated a pro0ect under a :/,. "e<1he reports to a Reporting =anager who is also an emplo!ee. *ro0ects have a uni6ue id$ name$ duration &in months)$ *ro0ect =anager who is an emplo!ee. Ever! pro0ect is under a :/,. Ever! :/, has a uni6ue (D$ -ame and multiple locations&address) from where the! operate. Design an appropriate set of Nor"a&i*e$ Re&atio#s to represent this information Reco""e#$e$ $%ratio#: -A So&%tio# '%i$a#ce i( a))&icab&e!:NA

B.S+L: A# i#tro$%ctio# Lab Exercise No: 1 Exercise Objective s!: Exercise: 1) 9rite 6uer! to do the following. 8et all the details of the products whose price is greater than 5 . 8et the names of the product whose 6uantit! is less than or e6ual to ' . 8et the details of all the products with the column names as *(D$ *R/D>)#?-A=E$ @>A-#(#A and *R()E. 8et the price of 1hirts or #-1hirts where @#A is greater than

PID PNAME QTY PRICE ---------- ------------------------------ ---------- ---------1 Shirt 10 600 2 T-Shirt 20 300 3 Kurti 30 350 4 Trousers 40 1000 5 S irt 13 250
Reco""e#$e$ $%ratio#: ' mins So&%tio# '%i$a#ce i( a))&icab&e!:NA Lab Exercise No: ' Exercise Objective s!: Exercise: =a%e sure that !ou have 1tudent table with following data.

ID --1 2 3 4 "

NAME -------------------Harini Ramani Ganga M !an M !an

ENROLL_DA --------10-JAN-13 10-JAN-13 10-FEB-13 10-FEB-13 10-MAR-13

BAT --JEE JEE C++ ORL ORL

9rite 6uer! to get the names of student who enrolled in the month of 4ebruar! &don+t use an! oracle functions) get the name and enroll dates of the student whose id is not 5. 8et the dates when the /R: batches where conducted this !ear.

Reco""e#$e$ $%ratio#: 15mins So&%tio# '%i$a#ce i( a))&icab&e!:NA C.S+L State"e#ts Lab Exercise No: 1 Exercise Objective s!: Exercise: )reate a table 1alar!?Det with the following fields.

Co&%"# #a"e

Descri)tio#

Descri)tio#

De(a%&t

Empid

=aFimum of 3 characters

Emplo!ee (D

-one

,asic

6 digits before decimal and ' after

,asic pa!

-1

"ra

5 digits before decimal and ' after

"ouse Rent

-1

Do0

DA#E

Date of Goining An! -otes

#oda!+s date

Remar%s

HAR)"AR'&' )

-one

Reco""e#$e$ $%ratio#: 15mins So&%tio# '%i$a#ce i( a))&icab&e!:NA Lab Exercise No: ' Exercise Objective s!: Exercise: .)reate a new table called 1alar! similar to 1alar!?Det B)hange the table to add a default for Do0 as 1st =arch ' 1 . BRemove defaults for ,asic and "RA. BRemove the column CRemar%sD. BAdd a column E-ame that can have hold at most 3 characters and 8ender with B0ust one character and set the default gender to E=+. BRemove the 1alar!?Det table from the database. B)hange the table name 1alar! into 1alar!?Det. Reco""e#$e$ $%ratio#: 15mins So&%tio# '%i$a#ce i( a))&icab&e!:NA Lab Exercise No: 3 Exercise Objective s!: Exercise:

3.1alar!?Det

E")i$ EA1'335 EA'3356 EA33567 1A*1'33 1A*'335

E#a"e 8eetha 1 "ari *rasad Ga!ganesh =ohan H 1udha -

Basic 5 3

,ra 1 1

Doj 1 -7' 1 31-6' 11 7-3-' 6-1'' J

'e#$er 4 = J = = 4

75

Enter the following records in the 1alar!?Det table using INSERT ALL. )reate another table called 1alar!?Det4 with similar structure as 1alar!?Det. (nsert data with 8ender as 4 into 1alar!?Det4. Reco""e#$e$ $%ratio#: &3 mins) So&%tio# '%i$a#ce i( a))&icab&e!:NA

Lab Exercise No: 3 Exercise Objective s!: Exercise: =odif! the 1alar!?Det table+s "ra such that it is 5I of ,asic. (ncrease the ,asic salar! b! Rs.5 for women who 0oined before ' 11. Delete records where ,asic or Do0 is null. Reco""e#$e$ $%ratio#: &' mins) So&%tio# '%i$a#ce i( a))&icab&e!:NA Lab Exercise No: 5 Exercise Objective s!: Exercise: E")i$ EA1'335 EA'3356 EA33567 1A*1'33 E#a"e 8eetha 1 "ari *rasad Ga!ganesh =ohan H Basic 55 3 1 ,ra '75 ' 5 Doj 1 -7-' 1 31-6-' 11 1-7-' 13 6-1'-' J 'e#$er 4 = = =

>sing the 1alar!?Det table write the 6ueries to find the following .

)ompute and displa! name and travel allowance which is 'I of ,asic for the emplo!ees whose basic is given. Displa! the result in sorted order of name and travel allowance. )ount the number of emplo!ees who have the gross salar! &basicKhra) greater than 6 .

D.S+L CONSTRAINTS Lab Exercise No: 1 Exercise Objective s!: Exercise: )reate a table called :eave?*olic! with the following fields Co&%"# Na"e Data t-)e Co#strai#ts De(a%&t

:eave?(D

(nteger that can hold upto 3 digits Hariable length string (nteger with 3 digits (nteger with 3 digits (nteger with 3 digits (nteger with 3 digits ( digit number

*rimar! %e!

:eave?-ame Da!s?Allowed? (n?@1 Da!s?Allowed? (n?@' Da!s?Allowed? (n?@3 Da!s?Allowed? (n?@3 )arried?#o?-eFt?@

1 1 1 1 1

Lea ve. ID

Leave .Na"e

Da-s. A&&o/ e$. I#.+0 3

Da-s. A&&o/ e$. I#.+1 3 3

Da-s.A&&o /e$. I#.+2

Da-s.A &&o/e$. I#.+3

Carrie$.To. Next.+

)asual leave 1ic% leave Earned :eave Restric ted :eave

'

'

'

'

'

'

'

=a%e Empid as primar! %e! for the 1alar!?Det table that !ou created.

Reco""e#$e$ $%ratio#: 30 Mins So&%tio# '%i$a#ce i( a))&icab&e!: NA Lab Exercise No: ' Exercise Objective s!: Exercise: ') )reate a table called Emplo!ee?:eave&3 mins) Co&%"# Na"e Data t-)e Co#strai#ts De(a%&t

Empid

=aFimum of 3 characters

*rimar! %e! 4oreign %e! . 1alar!?Det

:eave?(D

(nteger that can hold upto 3 digits

*rimar! %e! 4oreign %e!. :eave?*olic!

:eave?date?from :eave?date?to

Date Date

:oss?of?*a!?Da!s

-umber&')

Enter the following data. E")i $ EA1' 335 EA33 567 1A*' 335 EA'3 356 EA33 567 Leave .ID 1 1 3 3 ' Leave.$ate. (ro" 7-Gul-1' 1L-Gan-1' L-Aug-1' 1'-Gan-1' 1 -Gan-1' Leave.$at e.to J-Gul-1' 1 -4eb-1' 1'-Aug-1' 15-Gan-1' 13-Gan-1' 5 Loss.o(.Pa-. Da-s

#r! entering data with the incorrect :eave?(D EA23456 6 078a#701 578a#701 9

Reco""e#$e$ $%ratio#: 30 Mins So&%tio# '%i$a#ce i( a))&icab&e!: NA

Lab Exercise No: 3 Exercise Objective s!: Exercise: 4or the tables 1alar!?det$ Emplo!ee?leave and :eave?polic!&3 mins) 1. 1alar!?det table a. Halues in the D/G )olumn and Ename is compulsor! b. Ensure that the 8ender column to be chec%ed either for =ale &E=+) or 4emale &E4+) '. :eave?polic! table a. =a%e the :eave name column as uni6ue in the. b. #he carried?to?neFt?@ column should not eFceed 1 da!s. 3. (nsert some data and ensure that the constraints wor%. Reco""e#$e$ $%ratio#: 30 Mins So&%tio# '%i$a#ce i( a))&icab&e!: NA E.S+L OPERATORS Lab Exercise No: 1

Exercise Objective s!: Exercise: 9rite 6uer! to get the following details from the Sa&ar-.$et table. 1. >pdate the data with the new basic to be 1 I more than the current basic. '. Displa! the details of the emplo!ees who name begin with alphabet between EA<a+ or E"<h+ . 3. :ist the details of the female emplo!ees who have 0oined after G>-E ' 3. )ount the number of emplo!ees who have (D as beginning with E1A*+ 5. 8et all (Ds of the emplo!ees whose have ta%en casual leave for more than 3 da!s at a stretch. 6. 8et the leave details for the emplo!ees EA1'335 and EA'3356. Reco""e#$e$ $%ratio#: 30mins So&%tio# '%i$a#ce i( a))&icab&e!: NA Lab Exercise No: ' Exercise Objective s!: Exercise: )reate another table 1alar!?/ld with the following records Sa)i$ EA1'335 1A*1'33 1A*'335 E#a"e 8eetha 1 =ohan H 1udha 'e#$er 4 = 4 DNa"e 1ales 1ales "R J.

E13 JL 1E=713'

Rahul Hi0a! R

= =

#esting *a!roll

1. Displa! sapids and names from both the tables with no duplicates. '. Displa! sapid of all female emplo!ees from both the tables. 3. >sing the information available in both the tables find sapids of all the emplo!ees who have 0oined after ' J but not in "R department.

3. Displa! sapids and names in the form of CMMnameNN&MMsapidNN) who are onl! in 1alar!?Det table. Reco""e#$e$ $%ratio#: 35 mins) So&%tio# '%i$a#ce i( a))&icab&e!: NA

:.Orac&e: I#$exes Lab Exercise No: 1 Exercise Objective s!: :ie&$ )lient-o )lient-ame Exercise: )reate client?master table as given description. Ensure that there are no automatic creation of indeFes. )reate a indeF on )it! to tune 6uer! performance. Data t-)e ->=,ER&1 ) HAR)"AR&3 ) Co#strai#ts *rimar! Oe!

Address

HAR)"AR&3 )

)it! 1tate

HAR)"AR&3 ) HAR)"AR&3 )

*incode ,alDue

->=,ER&1 ) ->=,ER&1 $')

>-(@>E

Reco""e#$e$ $%ratio#: ' mins So&%tio# '%i$a#ce i( a))&icab&e!: NA

Lab Exercise No: ' Exercise Objective s!: Creating Composite Index

Exercise: Alter client?master table to create composite indeF for the for the columns highlighted. )ompare 6uer! statistics b! changing leading positions of columns in 6uer!. :ie&$ )lient-o )lient-ame Address )it! 1tate *incode ,alDue Data t-)e ->=,ER&1 ) HAR)"AR&3 ) HAR)"AR&3 ) HAR)"AR&3 ) HAR)"AR&3 ) ->=,ER&1 ) ->=,ER&1 $') >ni6ue >ni6ue cit! and state Co#strai#ts *rimar! Oe!

Reco""e#$e$ $%ratio#: 1 mins So&%tio# '%i$a#ce i( a))&icab&e!: NA

Lab Exercise No: 3 Exercise Objective s!: Creating Composite Index Exercise: 1. >sing the *roduct$ /rders and (tems table write a 6uer! to find all the write a 6uer! to displa! the name of the product and the count of the number of products that has been ordered. '. >se Autotrace to record the details. 3. )reate bitmap indeF for appropriate columns 3. EFecute the 6uer! once again 5. )ompare statistics shown b! autotrace at end of the 6uer! 6. 9rite about differences !ou notif! in both EFecution plan and statistics. -ote . (f !ou have more number of rows&in #housands) then effect of indeFing is shown better. Reco""e#$e$ $%ratio#: 15 mins

So&%tio# '%i$a#ce i( a))&icab&e!: NA Lab Exercise No: 3 Exercise Objective s!: Exercise: Drop the indeF created in the last eFercise and recreate the indeF based on the 0oin condition. Re-eFecute the 6uer! and anal!2e the result.

Reco""e#$e$ $%ratio#: 1 mins So&%tio# '%i$a#ce i( a))&icab&e!: NA

Lab Exercise No: 5 Exercise Objective s!: Exercise: )reate >-(@>E (-DE; on the *name column of the product table.& if !ou have a uni6ue constraint define on it$ drop it). -ow tr! to insert a new record using same name product name that was inserted before.

Reco""e#$e$ $%ratio#: 15 mins) So&%tio# '%i$a#ce i( a))&icab&e!: NA Lab Exercise No: 6 Exercise Objective s!: Exercise: 1alar!?Det E")i$ EA1'335 EA'3356 EA33567 1A*1'33 E#a"e 8eetha 1 "ari *rasad Ga!ganesh =ohan H Basic 55 3 1 ,ra '75 ' 5 Doj 1 -7-' 1 31-6-' 11 1-7-' 13 6-1'-' J 'e#$er 4 = = =

Aou fre6uentl! need to 6uer! and find out the names of emplo!ees who have the gross salar! &basicKhra) greater than 6 .

)reate an indeF to improve 6uer! performance. )hec% if the performance has indeed improved.

Reco""e#$e$ $%ratio#: 10mins So&%tio# '%i$a#ce i( a))&icab&e!: NA

'.Orac&e: ;ie/s Lab Exercise No: 1 Exercise Objective s!: Exercise: )reate a view that has data 0oining the ' tables 1alar!?Det and Emplo!ee?:eave using natural 0oin &refer slide 31 of '.3 1@: )onstraints) 9rite 6uer! on the view to get names of all the emplo!ee who have ta%en leave id 1. 4rom the view get the names of the emplo!ee who id begin with EA and who do not have loss of pa!.

Reco""e#$e$ $%ratio#: 15 mins So&%tio# '%i$a#ce i( a))&icab&e!: NA Lab Exercise No: ' Exercise Objective s!: Exercise: Create a view with empid, empname, basic, hra and gross (basic+hra) and net salary (gross loss o! pay days " basic) #sing $alary%set and &mployee%'eave tables( )et employees whose gross salary and net salary are di!!erent )et employees who earn above *0000( +se ,N$&-. command to insert all data in the above view( Can yo# insert data/ Reco""e#$e$ $%ratio#: 15 mins So&%tio# '%i$a#ce i( a))&icab&e!: NA Lab Exercise No: 3 Exercise Objective s!: Exercise:

Create a view &A%$A' with all the details in the salary%det table and comp#ted gross (basic+hra) col#mn !or employee who id begin with 0&A1 +pdate the basic and 2-A #sing views as shown below( ,nsert a new row with ,3 $A43*56 and other details( 3elete the above row(

Reco""e#$e$ $%ratio#: 15 mins So&%tio# '%i$a#ce i( a))&icab&e!: NA Lab Exercise No: 3 Exercise Objective s!: Exercise: 1. =a%e the EA?1A: view updatable onl! where the view conditions is satisfied. '. >sing the above view 1. (nsert data with 1ap(d as EA5555 '. >pdate 1ap(d to EA3333 data matching the view conditions. 3. Delete data that had 1ap(d EA3333 and 1A*1'33 Reco""e#$e$ $%ratio#: 15 mins So&%tio# '%i$a#ce i( a))&icab&e!: NA Lab Exercise No: 5 Exercise Objective s!: Exercise: )reate a view with Emplo!ee name and date of 0oining from 1alar!?Det table. =a%e sure that Emplo!ee names are uni6ue and not null.

#est the view b! adding duplicate Emplo!ee name #est the view b! adding fresh Emplo!ee name and date of 0oining. Drop the constraint.

Reco""e#$e$ $%ratio#: 15 mins So&%tio# '%i$a#ce i( a))&icab&e!: NA ,.Orac&e: Se<%e#ces Lab Exercise No: 1 Exercise Objective s!: Exercise: )reate an ascending se6uence A1)?1e6 starting with 1 reaching JJJJ restarts with 1 1. 1 and maFimum it go is JJJJ after

)reating a descending se6uence D1)?1e6 starting with JJJJ and that end with c!cle

and does not

Reco""e#$e$ $%ratio#: 70 mins So&%tio# '%i$a#ce i( a))&icab&e!: NA

Lab Exercise No: ' Exercise Objective s!:

Exercise:

#he 1alar!?Det tables re6uires generation of se6uences from 1 to J . #he ' lettered ,usiness >nit name will be given and this has to be prepended to the se6uence. )reate a se6uence Emp?1e6 and use this in INSERT statement to achieve this.

S+L= SELECT LPAD 09>4>?9?! :ROM D@ALA Reco""e#$e$ $%ratio#: 3 mins So&%tio# '%i$a#ce i( a))&icab&e!: /racle function LPAD can be used to add leading s. 4or instance$

Lab Exercise No: 3 Exercise Objective s!: Exercise: =odif! the se6uence A1)?1e6 created in previous eFercise and ensure that it now increments b! 5. )hange the Emp?1e6 so to count up to JJJJJ in place of J =a%e the last number in se6uence of D1)?1e6 to 1 instead of again with maFimum value after reaching to 1. . and allow D1)?1e6 to start

Reco""e#$e$ $%ratio#: ' mins So&%tio# '%i$a#ce i( a))&icab&e!: NA I.Orac&e: 8oi#i#B Tab&es

Lab Exercise No: 1 Exercise Objective s!: Exercise: >sing 1alar!?Det $ :eave?polic! and Emplo!ee?:eave tables$ write a 6uer! to get the names and Emplo!ee (ds of the emplo!ees who have ta%en casual leave in from the Ganuar! ' 1' to 1eptember ' 1'. Rewrite the same 6uer! using NAT@RAL 8OIN. -ote. NAT@RAL 8OIN does not need a 6ualifierP

Reco""e#$e$ $%ratio#: ' mins So&%tio# '%i$a#ce i( a))&icab&e!: NA

Lab Exercise No: ' Exercise Objective s!: Exercise: 0. MaCe s%re tDat a&& $ata i# tDe E")&o-ee.Leave is (or tDe -ear 1901. 1. Ass%"i#B tDat e")&o-ees ca# taCe EL Ear#e$ Leave! o#&- o#ce $%ri#B a <%arter "ea#i#B tDat tDere /i&& be o#&- o#e e#tr- )er <%arter i# tDe tab&e (or EL!> /rite a <%er- to Bet tDe tota& #%"ber o( EL &e(t (or a# e")&o-ee /Do Dave taCe# Ear#e$ Leave i# tDe 0st <%arter 0st 8AN7 29tD APR!. Pri#t E")&o-ee ID> Na"e a#$ EL &e(t.

Leave.)o&ic-

E")&o-ee.Leave

Reco""e#$e$ $%ratio#: ' mins

So&%tio# '%i$a#ce i( a))&icab&e!: NA Lab Exercise No: 3 Exercise Objective s!: Exercise: 9rite a 6uer! to get all the emplo!ees with the details of the leave if the! have ta%en. Add a manager column in the 1alar!?Det table and alter the data as shown below.

9rite a 6uer! to get the names and salaries of all the managers. 4ind all the emplo!ees who are not managers Reco""e#$e$ $%ratio#: 30 mins So&%tio# '%i$a#ce i( a))&icab&e!: NA

Lab Exercise No: 3 Exercise Objective s!: Exercise: )reate a view to get all the names and ids of all emplo!ees with details of the leave that the! have ta%en Reco""e#$e$ $%ratio#: 1 mins So&%tio# '%i$a#ce i( a))&icab&e!: NA

Lab Exercise No: 5 Exercise Objective s!: Exercise: :oo% at the tables below. 9hat do !ou ma%e out of the tablesQ

SID 1tudent

SNAME D!" ----------------------------------------------1 M#r$ Mo%%e 12-&AN-01 2 &oh' &u%$ 15-A()-02 3 *i%%$ *o%%$ 21-SEP-01 4 "i%% +i%% 22-DEC-05

SID CID EDATE Enrollment ----------------------------------1 2 10-&(*-06 2 2 10-&(*-06 3 1 20-SEP-06 4 1 01-APR-06 1 1 20-SEP-06

)ourse

CID CNAME D(RATI!N ---------------------------------------1 &#,# 52 2 RD"MS 30 3 -NET 35

)reate the tables with appropriate constraints. *opulate with the data as shown. 9rite 6ueries for the following.

&-ote that all the 6ueries must be written based on what is covered so far. )onstructs<functions that are not covered so far should not be used.) 1. 4ind sids and names of the students have enrolled for at least one course. =a%e sure there are no duplicate rows. 9rite this 6uer! using all the possible %inds of 0oin that !ou learnt. '. 4ind the end date for courses in the enrollment table if the course duration per da! is 7 hours. 3. 4ind the names of the students and the names of the course which the! have enrolled for. 3. 4ind the names of the courses that stared in Gul!. 5. 4ind the names of the students who enrolled in last 6uarter. 6. 4ind names of all students who have enrolled for some courses and whose age above ' . &"int. Recall that SESDATE gives the current s!stem sdate). 7. 4ind the sids and names of all the students who have ta%en Gava or RD,=1 courses. L. 4ind the sids of all the students who have ta%en both Gava and RD,=1 courses. J. 4ind the sids of all the students who have ta%en Gava but not RD,=1 courses. Reco""e#$e$ $%ratio#: 'hrs So&%tio# '%i$a#ce i( a))&icab&e!: NA

E.Orac&e::%#ctio#s Lab Exercise No: 1 Exercise Objective s!: .ypes o! $8' 9#nctions Exercise:

E#s%re tDat -o% Dave $ata tDat is sDo/# above i# tDe Sa&ar-.Det tab&e. Extract tDe (irst a#$ tDe &ast #a"e o( tDe e")&o-ee (ro" tDe E#a"e. Dis)&a- a&& tDe e")&o-ee /Do joi#e$ i# 1900. :or tDe E")i$ tDat Dave SAP> "aCe tDe SAP to SP :or tDe E")i$ tDat $o #ot Dave &e#BtD 6> a$$ 9s at tDe e#$ to "aCe tDe &e#BtD as 6. @se RPAD to $o tDis tDat a%to"atica&&- a$$s tDe re<%ire$ #%"ber o( 9s i#stea$ o( j%st co#cate#ati#B a si#B&e 9!. 4. Dis)&a- tDe co$e #a"e (or tDe e")&o-ees %si#B tDe (irst a#$ tDe &ast cDaracter o( tDe (irst a#$ &ast #a"e. 0. 1. 2. 3.

Reco""e#$e$ $%ratio#: 30 Mins So&%tio# '%i$a#ce i( a))&icab&e!: NA Lab Exercise No: ' Exercise Objective s!: 3ate 9#nctions Exercise: 1( 3isplay the last day o! the c#rrent month( 7( 3isplay the c#rrent date in the !orm: 9,9.2 o! ;+'<, .=&N.< .2,-.&&N 3( +sing $alary%3et table 1( )et the e>perience in years !or the employees 7( 3isplay the 3?; in 33@MM@<<<< !ormat 3( Comp#te the ta> !or the employees #sing the .a> table (created in the ;oins session) and display in comma separated !ormat with 7 digits a!ter decimal Reco""e#$e$ $%ratio#: 30 Mins So&%tio# '%i$a#ce i( a))&icab&e!: NA

Lab Exercise No: 3 Exercise Objective s!: 3ate 9#nctions

Exercise: @se sa&ar-7set tab&e to /rite a <%er- to cateBori*e e")&o-ees base$ o# tDe sa&ar- tDe$ra/ : Sa&ar- FG09999 8%#ior Sa&ar-=09999 a#$ FG 29999 Se#ior Sa&ar- above 29999 Ma#aBer @se Leave.Po&ic- tab&e to $is)&a- e")&o-ee i$> #%"ber o( &eave $a-s a#$ i( tDe &eave i$ is 0 or 2 reaso# sDo%&$ be $is)&a-e$ as HNor"a& LeaveI> i( it is 1 it sDo%&$ be $is)&a-e$ as H,ea&tD Iss%esI a#$ i( it is 3 it sDo%&$ be $is)&a-e$ as H:estiva&I. @se $eco$e!

Reco""e#$e$ $%ratio#: 70 Mins So&%tio# '%i$a#ce i( a))&icab&e!: NA Lab Exercise No: 3 Exercise Objective s!: 2ow to retrieve d#plicate records based on partic#lar col#mn Exercise: 1alar!?Det

:eave?*olic!

Emplo!ee?:eave

>sing the 1alar!?Det$ :eave?*olic! and Emplo!ee?:eave tables find -umber people in department EA and 1A* Average salaries of =ale and female emplo!ees -umber of people who too% leave month-wise in the !ear ' 1'.

Reco""e#$e$ $%ratio#: NA So&%tio# '%i$a#ce i( a))&icab&e!: NA Lab Exercise No: 5 Exercise Objective s!: Exercise: :ist the over all running total and department-wise &1A* or EA) total for salaries for emplo!ees from 1alar!?Det table. Reco""e#$e$ $%ratio#: NA So&%tio# '%i$a#ce i( a))&icab&e!: NA

Lab Exercise No: 6 Exercise Objective s!: Exercise: List tDe #a"e o( tDe e")&o-ees> $ate o( joi#i#B a#$ tDe #a"e o( tDe )erso# /Do joi#e$ a(ter tDe c%rre#t e")&o-ee. Reco""e#$e$ $%ratio#: NA So&%tio# '%i$a#ce i( a))&icab&e!: NA J.S@B+@ERIES Lab Exercise No: 1 Exercise Objective s!: Exercise: Sa&ar-.Det

8et the names of the emplo!ees who have salaries more than the average salar! of the person in the CEAD department. 8et all the emplo!ees who are in the same department as CR8eetha 1D. Tax

:i#$ a&& tDe )eo)&e /Do )a- tDe sa"e tax as ,ari Prasa$.

Reco""e#$e$ $%ratio#: -A So&%tio# '%i$a#ce i( a))&icab&e!: NA Lab Exercise No: '

Exercise Objective s!: Exercise: 4ind all the emplo!ees who earn more than people in C1A*D department. 4ind first 3 emplo!ees who are the highest taF pa!ers.

Reco""e#$e$ $%ratio#: -A So&%tio# '%i$a#ce i( a))&icab&e!: NA Lab Exercise No: 3 Exercise Objective s!: Exercise: Add a manager column in the 1alar!?Det table and alter the data as shown below &same as done in slide '5 of the 0oin session)

4ind the names of people who 0oined after =ohan H but before 8eetha 1. 4ind the name of the emplo!ee who has the 3rd highest taF pa!er. 4ind the number of emplo!ees who are not managers. :eave?polic!

Emplo!ee?:eave

9rite 6ueries to update :oss of pa!s da!s

4or 6uarter 1 &GA-$ 4E,$ =AR)"). Da!s?Allowed?(n?@1 -&:eave?date?to S:eave?date?4rom) Reco""e#$e$ $%ratio#: -A So&%tio# '%i$a#ce i( a))&icab&e!: NA

You might also like