Wa0003
Wa0003
.........es..
M05
Name i Nisha Hbi
Class : MBA EM 2nd Seroeste)
Role No. : 125
Submitted To i DH M. Shahid
Topic.... Date. Page No...
ston
(MEC2005)
Decobe the follousing commanla ay nantianing thike,
gntax and esample"
1 CREATE TABLE
WBe;The CREATE TABLE Atatement is od to cheote a nie
tableu a dotabaxe.
Syntax i CREATE TABLE tableName
Ccotuont datatybe,, calunal datakys,
EATE TAGLE Emplayes
CREA
EmployuID int NOT NUL
Name VOHchas0)NOT NUL
Depaxtment vanchax(30) NOT NOL,
ContatNo nt NOT NU
Email yaKchat(30)
PRIMARY KEY (EmplayeelD))
Maskating
5. wHERE
WAei The "uHEREd
to pilteN MeCOMdh and to extHact
anly thoe coMcda athot fulill a fecifid conditien.
SELECI colamni,calumn
EROM tahli nme
WHEREcondittoa4
Topi... Date.............*. Page No...
Eaamplei
SELECT EablaeID, Name ERoM Emplayts
WHERE Debaxtnent a ' HR
Outpudi
EmployeeID Nome.
03 Chuis
ORDER BY
asLendian udeacnding
3ELECI ealumat, calumm2,ee
FROMtablenon
ORDER AY colan Ly calumn2, Asc{DEScy
Examplei
SELECT EmployeiD EROM
oRDER BY Noume DESC
Qutput
EaployeLD
102
AND OR ANOT
WAeS) Th 'ANO' opexatsiwd ta filten ecasca bastd on
iall conditten a
|Topic. Date..... Page No.....n
Exafnplei
SELECI Name FROM Emblcyees
wHERE Depotmnt'HR' AND EmployeID T0
Output NamOe
CARIS
Raj
SELECI Nome ,EmplayeID EROM Enplayeea
uoHERE NOT Depaxtment =HR
Topic. Date. Page No....
tput
EmþloyeID
102
Tsha
SLECI colionfcalunan 2
EROMtabl nce
wHERE calimnname IS NULTS NoT NOLL
Examplei
SETECI Emplayee ID Nanae EROM Eoaployeea
OHERE Emol IS NUL
Output i
EmplayeID Nome
UPDAIE
IODELE TE
DELE IE'à ed to cdeleteeiting Hecand inatabde
WHEREclaee shecilie ushich ecAHdi to oe dalted
tabletle bl deleted
agntani
DELETE FROM table Name HERE COndition
Example
DELE TE FROM Eahloyes WHERE Emplouee1D=lo
DROP Table
DROP TAALE data delete dae table tomhlitely
DROP TA BLE tablenCme
Exanmpli
OROR TABLE Cwtome
Exampls SELECT Top 2 Name FROM Enylau SELECT Name fRoM tmblayes
wOHERE EmplbyeID Z104
LIMLT 2
Topic. Date.
Page No.. ........
Qutput i
NAMP
SIA
CHRIS
Syntaxi
SELECT SUM(Connnam) 3EIECT AVG(coumn neme
EROM tablname
EROMtablenan
uOHERE concitien OHERE Conditien
xamplai
SEIECT sUM(Quant SELECT AVG(Pce)
FROM Ondendtala EROM Pacdcte
15. JoIN
UAe A JOIN cdouseiA Ad to CAmbine Hos omtuo
mone tabler bosecd on a tlated calnmn batuseen them
UNION
UAe The 'NION' spaxatex sd to cêmhine the eult-st
tuo a maMe Aclect atetemande Evexy SELECT tatemd
usitlain UNTON mst have tai eme nuAmbln a colunaLsith
sinilaH datathhei. To clloo duplicate value, ise UNION ALL
HAVING
VAe he HAVING clause as addad to SQL becausL the HERE
ALTER TABLE
The ALTER TALE' tatement is ed to cdd,dalete a
nodliby clumna in nexistng table . Tti ud ta add
and drAp vakicLA CSnitHQinda an anesting taal
To To ctotate ucoturys
ALTER TAGLE tasla nane ALTER TABLE tablo name
ADD cnlnnome DROP COLLOMN colwmnname
datatyt
To sttntemt t t o t t e b t t
ALTER TABLE tablo name
RENAME COLUME ald nage to nen namne
Exampu i
ALTER TABLE Pesonb
ADD Dateo Biath dates
ALTER TAGLE Posona
DROP COLUNN
Dateoksixat