You are on page 1of 6

718.

0 SQL ‫מבוא ל‬
His
r r
Database
J
1 2 p.pro law sofa f edify82N fist pegs pinepa Dying folk
82N risk
DB pint 82WSenoise ink said 8W
Be Pipff find 82M
if
pion ma 2mA 421cg saw sifas W
pionsPier if 21804214Null oxo
253
‫הפשטה של נתונים‬
viewlevee
i r s p A icpncook a emos poof incl
than
Type customer = recored
two fops said Sapd 421 Miss xD ins saw Bp
www.j.ozs
logical name: string;
street: string:
city integer;
pinned lab pig DX W PINS p.ec pile Pista Pym pile o.O
physical
End;
P a P Oni P Na o.o a web gain an isaf

‫תבניות ומופע‬

gap rub sins PID DDLooo Se 218 jispo Dan


(Data Definition Language)
jas
pas seok Pony Pinot nylon site 7,24 now no

lad managed pilot INDML Pig


115(Data oooo Wen om sow
Manipulation Language)

‫בסיס נתונים במודל היחסים‬

ynjnot nixed n.nu pion il self c fo folk


i deaf 2in pe afsc

is nipa ma H Pe S's

B
Gfp a ios u 12Not sit on
ifoes 2in Pe saws D8
a

7soo 7 1234
pm sina.fm isaid I i Bak p no pins ios D8
6700 5 l 2212
is
20188882d 23W7710Do
6480
DID D8pro Hot m ik 7710 Bo
pillow 5 is 3312 a spa nixes onto my
n'acid if in ga us lime and pro Null
‫מפתחות‬
t.G.pg.EE 8dd8aNlbBanfacs sin pops e e nylon fork ik Dios fo snow
‫ שימוש‬- ‫מפתחות‬
likes it 108 Pak p IS sina.se Ssc g s
s so Mbf 702 88 not 21h is on a Him a folk fo mon e 2nd ont abc D8
How µ Sidi go on
piopaj.ie vfo nd Mah Dios 2 8 noon k mfs n W fo n d fan now

14Nmad Pion anime


ios's nwo nose p fspa innate ante tea man

‫שפות שאילתות‬
p.gl o.oxozwepxemem1io3d a
aTae Se
asleep
a Gps was dibs at A Pixie sow off So C ik anic msn.ae Gianna
Ps mm 208 Gia assai was idk inn pile ons my 8 2372 l f
3+4 ‫פרקים‬ SQL ‫מבוא לשפת‬
r r
e
J ‫בסיס נתונים של מעבדת אלקטרוניקה‬

pion sips 80 am a mad


pig Se noon im
∘ instrument (sid, stype, manufacturer, myear)
Soos fiveo ∘ client (cid, cname, address, phoneno)
∘ part (pid, pname, supplier, uprice)
∘ repairorder (oid, cid, sid, rdate)
∘ repairpart (oid, pid, quantity)
riot
∘ bill (oid, fdate, totpay)

CREATE-TABLE ‫ע״י שימוש ב‬ :‫בניית טבלה‬

CREATE TABLE instrument (


value 1 (value type) a pep ant Create Table p.fm 2ND eines msn.bcsiz.fm A
value 2 (value type)); P mo mo aba se p ok ow
Jgpportanf
PRIMEARY KEY (key from table)

FOREGIN KEY (keys from table) ma 2


REFERENESS keys meaning
P noon ink pie
knifes
pass CREATE TABLE bill ( CREATE TABLE repairpart (

www.ask.n.fhon.sd
oid int, .
Hae aka Pe fdate date, .
topay float, PRIMEARY KEY (oid, pid)
FOREIGN KEY (oid) REFERENCE bill,
PRIMEARY KEY (oid)); (pid) REFERENCE part );

n.fm
peg
INSRT INTO Name VALUES ( list of values) Bcf noon
was
INSERT INTO bill VALUES (123, ‘5/7/2019’, 1000) , (231, ‘12/1/2019’, 500)
as INSERT INTO
exes 88 at f of us 88

:‫שאילתות‬

HIS ax 580oh 23W A sea on


h Select A₁ , A₂ ...
B 3 jBBgg
From r₁ , r₂ ....
PIM d Tbs so He 4 Pion est r neko
c jars on g Where P
F WT n sa P 8 Cfpa on nie f ta est P
q
Aaaa

Sid stipe
Mbf infild
Jmportant Select sid, stype
A12 Tv ftp.sf not pin da fo G ca mis od Il 3J I
From instrument 1334 Pc
Distinct lifers 18 l20 Bss Pc
Ones and
1select isnt
Select sid, stype Sid stype
From instrument cuztoaster 20 s Mf 173110P'Tessa fo fo al mis ood I 2
Bi
Where myear > 2015 573Micro
select 5
pg9
where
Not o Distinct Select cname
From client, instrument safeMsfnote inpf side 3
Or a Ali Where stype=TV and
I am client f instrument is sand n.de of pies
Between I'mshoo client.cid = repairorder.sid and 1
ft where a f Sina a gifos
fpf t.fm A repairorder
instrument.sid = repairorder.sid
pas
AS ‫שימוש ב‬

Old_name AS New_Name
i AS nicious HAS A wide In the cfp on 8 Pas Pe MS H G
‫פעולות על מחרוזות‬
glacis P van pill je as 183 w Isin fo n
Where address like ‘%‫דוד‬%’
anse Pike past msn.rs si nu n fo est
Dina sia de
Where city like ‘‫’_ _דוד‬
no Pisco past sa 2210 is 23 t
Like
axeheads Ia Pinos nee icon I the eine

‫דוגמאות נוספות‬ :‫שאילתות‬


e in Mf Piso nipa Piso pen od c f e 7son fav gaff 10 Se a Icsa f
Select oid, totpay, 0.9*totpay AS discount
From bill DidtotpafDiscount aye Bill one In B
Where totpay >750
sean point 12118 Dna

2 if 8 pm yips ink 8 7Soa Ssn win and a 8 P e p Bo 2


Where 0.9*totpay >750

3 ra foisa if pl who ftp.sfpjiep.siex 2 mas l one anpf 1h31 3


Select cname, r₁.sid, r₂.sid
From client, repairorder AS r₁ , repairorder AS r₂
spin Na je fe nasal nips Pe IC's
Ink Poo goin Pinex is fo

f
Where client.cid=r₁.cid AND
client.cid=r₂.cid AND
r₁.sid < r₂.sid AND
r₁.rdate = r₂.rdate
a yemen
pf

orderby a ex
:‫מיון בשאילתא‬
214 Has shoo as 1H
Desc
2min20s ik fans x no Asc
A no µf IX
Pifers Pix of an naos2.3ns a q im Maen a naos pi o pins of Pym wires a x 37.4
Select *
From bill pod
ORDER BY fdate as ASC, totpay DESC
a ‫פעולות בין קבוצות‬
Union o
113127 2in k
Intersect
11317 1 s pins Except
lap 1 a non

91710 88 71108 23 did you 11 3 11710 NtsbAfl


all
soon sift Omens e mfs
8
Union all
Intersect all
‫פונקציות הפעולות על אוסף ערכים של עמודה ביחס ומחזירות ערך בודד‬ :‫פונקציות הקבצה‬
p naps nismo
83W yr avg
i
fess pidginpar min

0
ttmcaugcxD
gnnkf8fnk7a3p7d3pD ftp.nf l'Jkf it
BBooB

prime
Hopps sum
max

pix pix
pions w i count

ftp.sfopfieenni.rs a six ok 131


Select MAX(totpay) AS highestpay
FROM bill I was Pyle PINS His sister fopf if n.fm fo fo adf.nznji.fi
bop pss fo fo aah ppsnfafs.am pas seok Sk oo csaicofeyi3 nu

Group By
Mpa a pimp sis afloat

on ink is.am nylon ios map onion 31 Group By apps Hoo


7h31 s k ane safesmap 68
Group By ins man 73 pair mispias find select a n own nylon
1 Parada having He select a pan d 3 a 5 d sua IO Iff Group By a eine n n l S

Pla Kans was A Distinct a


as mood 8old orderid ink
was sinful
1
Pss Pah noo ki pdoo Oid Cid Sid rdate nips D8 tianya.rs no ix l
f
Select cid, COUNT (DISTINCT oid) AS norders I 123 2
From repairorder
Group by cid
e 123 snaps a in
pissoir.to

I 321 Mf
2 SHI Cid of
125 sws 3 g
IS f into solo Count
Dias Nile je Sf 821
2
2
127
129 J 2,3 P8037 SHION
cidborders cis sign ni nff f
25 0 1

In if I fp sad Ania 2018 If I Dn fo 7128 nips b Pfee Sfm Pim she 1131 2
2
Select cid, SUM(totpay) AS megatotal
From bill, repairorder
Where repairorder.oid = bill.oid AND 1 fl Alfa nk DD k
fdate < ‘1/1/2018’ nk
GROUP BY cid pha
ftp.anlpfijjfaps.de
‫בודק תנאי על קבוצה של ערכים‬ Having ‫משפט‬
Having
Aapa psia exes
a
Group By a Mk p Having a ewes
7377
span Daf It
where annus pipes Having a Piya
pass as pan

Macias Mfa
ra 2500 d nad Paso P m fo fo Hee 88M Pi one nips 6 me i 31 I
1
Select cname
From client , repairorder AS r, bill
Where client.cid = r.cid AND bill.oid = r.oid
Group by client.cid , cname
HAVING SUM (totpay) > 2500

SS ease on
pens Piso fo Ho p Hoa p.ofnapiooeym.ms 2
Select bill , oid
From part, repairpart , bill
Where part.pid = repairpart.pid AND bill.oid = repairpart.oid
GROUP BY bill.oid
HAVING SUM (uprice * quantity ) < MIN (totpay)
70377 B pies µ
I n.se µ avg x
minimax

totpafsh.sn

s SQL a lens is
ins
g

an Select
qp
afsc prom From
pm My

gawd So PI P s Papa plea Where


of Puan na Mfp Group By J
ios H Is p s Having M
IT
ios H Order By
3 5 1

You might also like