Module2 Part2 Basic SQL
Module2 Part2 Basic SQL
TReF 04 FALsE
emai
Tt i bess:hle to 8pug7 he dototyh«s gkech ata:hut
t y , altuunatiuely , a domain can be clae.
t h e domain neme een b s d i t h +h ataihutu
Spetigitahion. This maks e to eharge +h
et +ybe gem
a
domai tkat- is 0sby numtou^
aHsibuH8. in a schtmna.
CoNSTRAINT ENPDEPTFK
FoRETeN KEy(Dno) REPERENCES DEPARTHENT Onumbta)
ON DELETE SET DEFAULT N PDATÉ ASCADE)
ConSTRAINT DEPTPK
PREMARY KEy Dnumbu
CnSTRANT DETSK
UN&UEOname),
ConNSTRAINT DEPTMeRK
FoREre REy(*ss,) REFERENCES EHPLeyEE SSn)
ON DELETE SET DEFAOLT ON OPDATE
CASCADE)
the ORELGM
Rnntol intyiy s Apfrt
KEY elauAt.
6OH UPDATE.
DBHS4A SeT NULL A sET DEFAOLT
Actien taken by th
is he Jame dA he+h DELTE 4 ppATE
Ciin omes to Conat ain'
heu a Confha:nt m a y b ivetn ConMtsaint hame
( he Keyuo8 Con-CoNSTRAInT.
lowin
The nam e otl Consthaints thin a otiul
Ketaieva uaits in Sa
6-3
S8L hos one bC Btottment f& taittiny
infamodon no a atabese the SFLECT
8tatim1nt.
follousig fhm.
wHERE &has he
SeLFT<altnibute list2
2 toblt list>
N FRoM
LOHERE 2Con9+ion
whea tL
elationa ta.
SEFr han Lrem ASSs
DEPARTHE T, EHpoyEE
SHERE Dam :R«4tarth ri) )humke e
l eRE cl t , +he tere
Aett
Th Con on Dnunbt Dno Call e Join Con+ion
becaue it Combints totu Ontfon DETARTHE
0ne fuem CHploy6E
Auy that inuelu4s on Stteion Jein Coniien
Selett
bos ion altbutts is nouor) a a
-
e t t -Join tuy
k teusinaxamble
ScLFT E.Fnamt,E.Lname, 3.hem S.Lhamt
FRe EMPUyEF E , EMPLofEE ASS
HERE E.Subunssn = S.8Sn
Can n t
AsteaisR
UnAbecf
HERE Cause & Use af he
m t n t t t s o SaL hane
Two
nicts no Cen
indicatag no eenton on
Amiain
HERE laun
the aelation
henct oll fuplls of
tuple selecton; elaust uelfy 4ane selete
Apecifal in he Ro
& h e queay nehult,
aeloton SpecifX in ha
i6
m e han en ha
haae Tno wHERE Clause, hen
FRoM elaus
hle tuple ombinotiong of these
-
CRoSS PRoDUT a
Saletio i Reltt.
SELECT SS
PRoM FMPLeyEE
SELET SSn , Dnome
ReM EHPloyEe, DEPARTHENT;
he EMPLoyEE ttle
FRo EMPLoyeE
HEREF Dno-5
Retivis al the ataibute oluts of any
EMPloyEE Who ks in DePARTHENT numl ta 5
SeLECT
FRoM ENSLoyEE, DEPARTMENT
Speifs
he eRoiS PRoDuT of h FMfloyeE.
DEPARTHENT elations.
Tebles o &ts in SBL
Se lo y Saloy
30ec0 3coct
4occd
25000
250c0 43ec0
4300C
25e08
Fin Rsutts e 9eL qutni -o> I b&A
L
SBL has y intxhoratt emt o the Bet+
opehtrong-
Setnion (UNsOn), 5et Hnte (EeEPT), 4 Stt inte-
chien (IMERsECT) opatien The 3elationg Jatuting frem
hst Aet chemotiens ets fuples; th«tis
tulas e
e
eliminatd om the u t
Suptcote
SAL lo has Coutsonein multiat 05euationg, whth aefelless-
by by the KeyeendALL
ALL(UN*ON AUL, ExcePT AL, INTEPSELT
ALL). Thei Mtsutt ue multisets (Splicats e t not alimingte).
matt hint
Hee pouiioen Cond+ion on ontyans ofa
Com
the LIRE Comheioen cpuetos.
chomett 8tmint, 4
N two ugtave
aA 8puigied vsint
aabial tuings of3emo O
ehanottu: utsleceg a n uhituoy mo
moe ehametttn, 4 he Undjtoue() atjleces a Birale
haotta
Exomlag3
uty 12; Retaitut all empleytts hese odlsatss i in
Houstor , TRxe3.
FRoM EMPLoYEE
HERE ASSaess lLE ,Housten,Tx .
LNSERT Comamon
INSERT i Use9 +o odaingle tuhle
foum,
in 8implest- we mujt Spetifytha
elation name 4 he
t o a u eleation.
he tupta.
&t o Valueg om
b i s t e l in the Bame oden
The tlaluas Aheul
in ohh the Coapornding atauibutts wee 8prigrin
TARLE Command
the CREATE
.4+)
-in Beeond doum he INSERT Atottmert alletws the wa,
CAA INSERTINTO
ELeyEECmeme, Lname, Dne. sn )
VALwES(Richax, Maini,4, 3298653')
AHui butts net Spetijit in UiA Oue t te theia
DEFAULT C to NULL
tuples inkttt oulelleu o inteuty ter Abio:it
het Cer be Aprtii
A leaaitiir +he JNSEP
(crrrer rAta t utipl. tutl
inte Atletien in
anS
(nurter wi+ tatins -tk. ele be
an ceinit te ith t u t t e furs.
C CREATETABLE eRKSONSNFO
Em.no VARCHAR(6
Pseran NAReHAR(15)
HeumsMALLK DECIMAL3,))5
INSERTiNio wRKSNLINFO( Empneme, Brege
Heus per.e)
SeLeT ret, P.Pheme, w.Heu
Re ReTET P, weRKSCN O, EHPLoyEE E
tERE Pmh .ho AND.ESSn-ESSn
n the aheva u y a toble twoRKS_ON-INfo i tarstd
Daeie Commone
in
In 0th tle tiong afttn h tuigtit ocbiong
se 8petifits in the Mftaen tiol intety tenstueinty
f the DDL.
eml
DeeTE FRe HPLYEEF
6OHERE Lnome Buoon;
OPDATE EMPLoYEE
SET Soloy Saloay *11
HERE Dne 5,
NULL DN DEFAULTT
05tha heuo atauibutu value