Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Name AN RATI DT litr KUMAP PED Dy

Keg no: 1 (l282


Roll no: S4 Set 11
Sechen kT tUN CA-4

1) Create
CREATE TABLE Mployees t
EMP_TD TNT PRI MARY KEY,
Frst Name VARCHAL (So)s
LastNaQ VARCHA RCo)
Depastment I) TNT,
Shlesy DEcTNAL (o,2),
Depaztmerdh
FoRETGN kEY Depatmet ID) PEFELENCE
epostnentIO);
--Create te Depotmert table
CeEATE TABLE De patmend(
Depatmend IO TNT PRTNARr KEY,
Nave VAPC HAe (so),
Heod db-Depast ment VAPC HAP (oo)

Create te jobs table


CeENTE TABUE Joby(
Job70 TNT PRIMALY KEY,
Job-TI1LP vARCHAR (o)
DepatnentT0 TNT;
Pag 1o7 1s
Naue AMßATT DT (EEP kUMAR pEDDY

Secien : KolUN Set-41


FoRELGN KEY(DepaxtuentTO) PEELENCES
Depashant (Depeatend1)

Otput:
Casy ok, o row8 afected (o.lo Kec)
Quy oK, 0 rowg abfecte d lo. oSse)
uesy ok, Ovows aleched o.o4e)

-- In sert valueg EmployeeTnf tabe


inte tho
INSEPT TNFO Employee Inß (FirekNane, Lot Nang Depushat In
VALUES
('1o hns Doe', 1, 60000- 00)>
(Tane','Sh 2,sT00o-00)5
(Michaol'y 'Tohn on'; Ay 62000-00),
(Eily's ilsen', 3,S)ooo-o 0).
('Dovid's 'Bveun, 2sfsuooo.oo))
(Sasah', Lee's 163000.06)
(James, Andoasen3,5000,0o)s
(Tennit, 'Moatneg', , S6 00o 60),
6u000 oo),
(Way's Dais, 3 59000.0o), Page
DIIEC kUMAp PEDy
Name : AMßAT1

Pollno:9 Set. 41
Sechon: k2lUN
the Depastmond Inl tabe
-- Ihset values indo
TNSELT I NTO DepakenenTnf (Depathned Nono, Heod. . t
MeNd. Nare)
Vaus
('He',ohn Nanages)
('Fnance', 'tane Superviso ),
('TT'; ichael Direc
hsest valus in the TobInto tble
TNSERT INTO JobTnfo (TobTite, Depastent -ID)
VALUES
('HP Manag'»),
('Accoundout, ),
(sttwase Engnse,),
(Finante Morag, )s
(Recnoite', ),

(Finarial Ava'3)
Netuk
('He.Atsihad ) ;
Name :AMBAT1 TliP KUMAP PEopy
:2||28
Roll nosa
Sechon: K21UN

*6 retricNe data fvem Eeployer Info able.


Code:
CELECT ^FROM Enpleee "Info
Enp_IDFrstNane Last Noe Depostst
John Doe 60000-0o
Jane Sith 2 SS000-00
Nichael Tohnson 62000-00

5
Enaly
Darid
twi l&on
Brown
S8O00-D0
SY000-Do
Saah lee 63000- D0
Jame Andeyon 54000.00
Jenides Mortnez S6000- Ô0
lobeit Haois Su000-0o
10
Pay Davig S9000.00
6 vehieve data trem Degasthentna tabe.
Code.
SELECT *FeOM Depautmend Ino,
NhueAMßAIT DI (E EP KUMAP RE DDY
Regno :12 i|2$2b
Sechon: K2|UN K2lUN - Set!
(aoutpot
Tpattent table:
Dgpatheat 1D Depastm Nane Nead. c- Depashuad.Nane
HR
bhn Monages
Anance Jane Supervi3e
Michael Dlrect

| To retieye data eM Tob Info table


Co de:
SELECT *FlOM ob Info:
Job Irto table
TobID JohTitle Depantment TD
1
2
H
Monags
Accountant
stwnse EnoineR 3
Finance Mounaget
3
6 Pe cvuites
|Sytems Analyt
Francial Aralyet
Nehogk ErgjnaeA 3

Page s ofIs
PEPDY
Name : AMRATI DI LEEP KUMAP
Pollno :Sa
Pegno: t2|128?
Bec hon: kl0N
Set-44

We
Code Constraint to Emp_TD colunn
--Add a primasy Kay
ALTER TABLE ENPloyee In fo
ADD PPINAer KEY (EMP.TD);
-Set DepatmendTD column t not olo NO
valuey.
ALTER TABE EnployeeTnfo
No0TFy Depatuent îp TNT NOT NULLS

Dutputg
OAdding priaay ey conhaint to 'EpTb':
Utput:
Quot ok, 0 vows affected (0-0S 2)
Records : o Duplicat ;0 waings o.
(Moty 'Dep Tp' to not allow NDUCValuoy
utput:
afected (o.lo a2).
Re cords to Duplicatey : b wang
Nne ANßATI DI LE EP KOMAR DE DD Y
Re no: 2ll28D
Sechen.K21UN Sed-11

Code:
UPDATt JobInfo
Job.Tttle - 'Vce Resicdend
SET
wHEPE JobTD =S

Output
afeced,Co-66 s2c)
Guey Ok, 4 row
Rows mathed: 1changed:4 wasaings 20

(a) Code:
SEECT#
FPON Eapoyees
FULL OUTEe JOTN Depastnt ON Employees. Depasthand D
DepatmontDepatuontTD

(b code
SELECT t
FeOM Enmployees CN Enployees.Depahed. TD=
INTER JO1N Depaterd
DepetinondDepatant. TD;

Pagea o l5
Head
Le NULL
detWchod
- IT s4000-00
3
Davis May lo
3
aras Ton 64000-00 Hasw? Robet 4
erngc Taue Finonce 56000-002 Natirez Jennie;
2
ecte Hehad 37000-0o
3 Ardezor
3 Tames
HP
62000-00 le Soiah 6
1 Broaon Daid s
4o Tane fnonce SUD00-00
2
2
chd Hichocl 3St000-
00 3 son wil Enuly 4S
IT
62000-00
4 Mchae|Tohnson 3
esuiso Fironte
Soa Suth Tane 9
60000.00
1 Doe John
pashant DepshtMe-TD Na
tait topFivgtN
FUoutput:
l
Set-1? UN
Sechen:
Kz(
DEDDY UNAR D2LEED ANßATI
Noe:
DDy
Vae: AARAT3 O/IEP KUMAR PE

Dollno: s9
SecHon:K2lUN
Cuieut
Eup FistName Lat Depat Nao Head of- Dopod
Nuea) Salay end 1p
Ooe oO00.00
3 MichaTohngon A 62000.00 1
Tohn
Mangcs
|6 Saoh lee 63000.00
Tane Suith Skooo.00 inonte Taae Supeikch
S David Brouon2 2 Fincnce Tane SuperviB0)
T6 D60-0O 2 Fhance Tae Superise
Mickael Divech
thuly uilBon3 58O00e-003
Euily IT ic ha Dive cto
Ardeten S0o.00o
Nay Dais 3 TT Nichael Divecto.
S4OD6. 003
Ne: AMßATT DI LE EP KUNAD pEDDLY
Reo: 12I|287D
Sechon: k21UN
Rollno sa Seti

aJ colewg om 'eaup leyey" tab le


Code:
SELECT*

FRON ploges ;
Ouput:
Expbyee I D hrst Nae Last Noane Sloy
Tohn Doe
Jane Sitth 62 000- Oo
ichaet Johnon 48000- 0o
S6O00 00
Exily
Daid
wil&on
Brown
Sasah Lee S3000- DO
Tames Andes on S000. D0
8 Jernites Maihnez sS000. bo
Robest Haig 64000.00
Darns S9000 O0e
May
Petnese names o eupleyay with
wrth S,0o0 om eau table:
Coale.
SELECT first-Nae, lat Name
FeOM
ltERE Saliy s0000;

Page
kONAP PEDPy
Nce: AMAI DrllAD
Veg no |211252r
Secion: KeluN
Pellnss
ootput
fust Nant last. Nosaal
John Doe
Jane Saith
wilson
David Brown
James Andotion
Robet
Davis
Naty

ootputpot:

() Tobs table:
Co de:
SELECT DTSTTNCS Job1ttle
From Jobe.
10b8

Page n s
Pecien: KotUN
Poll no:s4
otput

Calesçovson

IT apeciali.

Code
9E (ECT UPER (first. No) 4s Uppeaoy FivdNouo, UPPERllod. NandAs
UppevrooLat Nao.
fvorn ereogs,
Code

John
Uyprcoe lat Nao.
Doe
Jon Snith
Micha Johrgon
ilgor
Dond

Nostne
Qollno, s9

Rohieve
Cocdo
SELECT Tist Nano, \at Nao
FRON Eployees
O4EDE oeateat 'Saley'
botput:
Fist Noe at Nae
John Suith
Doe
wikon
Lee

b iat iob itleg of euployes, who en blo uob,o00 60,0o.


SELECT OTSTINCT JobTit le
3ETWEEN Yo60o AND 60000
Output
Job tit le
Salos pereor
Narone
Firorci Aralyl.
He Speclaltt
He Mana ges Page isots
Nawne: AMATT OI LEEP KUMAD REPny
Regno: 12 |2870
Rolno: 5q
Sec hon' K2lUN Sed-44
nomes of euplbpey toted in eternlng
ode
SELECT irst-Name, Last Name
FROM pleyees
ORDEP Gy ve Dato DESC;
Ouput:
FvstNoe Latnae
Salah, Lee
Michae Tohnon
Texite Mones
Pobet Hals
John Swith
wilßen.
Davi d Brown
Jaues Andeon
Vane Doe
n eoch depeat
(tt depash-ont amcg
3ELECT Deputmand, CouwT*)As Nombe d- trplogey
Code.
FROM Enployees

outpt:
Dyashunt Nlunbes ot-Enplosees
Sales
Maskeng
inane 2
2
Name; AMßATI DT (EEP KUMp PE DOM
Veho: l2128
Sechon: K2lUN
Rol no:sa Set.4)
Petieve naes dot emplooes who lagt nome tate aith
and job itle is aot Manags
Coe:
SELECT Fst-Nane, Lat Name
FRON Enloyee,
wHERE La-Nae LIkE '3y2 aND JobTitle 3 Manag9
Dutput:

First_naue Lat Noue


Tohn Smith
wilso
Sajah Lee

You might also like