Sie sind auf Seite 1von 5

Oracle Database 10g : Les fondamentaux du langage SQL (I) 5-31

Exercice 5
1. Ecrivez une interrogation pour le dpartement HR, afin de gnrer les adresses de tous les
dpartements. Utilisez les tables LOCATIONS et COUNTRIES. Indiquez dans le rsultat
l'ID de localisation, l'adresse, la ville, le dpartement ou la province, ainsi que le pays.
Utilisez une jointure naturelle afin de gnrer les rsultats.
2. Le dpartement HR a besoin d'un tat de tous les employs. Ecrivez une interrogation
permettant d'afficher le nom, le numro de dpartement et le nom du dpartement de tous
les employs.

M
o
h
a
m
e
d

G
h
e
n
n
o
u

(
g
h
e
n
n
o
u
m
@
y
a
h
o
o

f
r
)

h
a
s

a

n
o
n
-
t
r
a
n
s
f
e
r
a
b
l
e
terrogatio
dpartem
s
f
s
f
eeee
dddddddd

GGGGGGGGG
hhhhhhhhh
eee
nnn
nnn
oo
uuu

((((
gggg
hh
ee
nn
n
oo
uuu
mmm
@@@
yyy
aaaaaa
hhhhhhhhhh
oooooooooo
ooooooooo

ffffffff
rrrrr
)))))))

hhhhhh
aaa
sss

e
d

G
h
e
n
n
o
u

(
g
h
e
n
n
o
u
m
@
y
a
h
o
o

f
r
)

h
a
s

lll
iii
ccc
e
nnn
ssss
eee

ttt
ooo

uuu
sss
e

tt
hh
ii
s

SSSSSS
tttttttt
uuuuuuu
dddddddd
eeeeeeeee
nnnnnn
ttttttt

GGGGGGGGGG
uuuuuuuuuu
iiiiiiiiii
dddddddddd
eeeee

Unauthorized reproduction or distribution prohibited Copyright 2009, Oracle and/or its affiliates thorized reproduction or distribution prohibited Copyright 2009, Oracle and/or its aff thorized reproduction or distribution prohibited Copyright 2009, Oracle and/or its affi
O l D t b 10 : Les fondamentaux du langage SQL (I) 5 31
Oracle Database 10g : Les fondamentaux du langage SQL (I) 5-32
Exercice 5 (suite)
3. Le dpartement HR a besoin d'un tat de tous les employs de Toronto. Affichez le nom,
le poste, le numro de dpartement et le nom du dpartement de tous les employs qui
travaillent Toronto.
4. Crez un tat afin d'afficher le nom et le numro de tous les employs, ainsi que le nom et
le numro de leur manager. Nommez les colonnes respectivement Employee, Emp#,
Manager et Mgr#. Placez l'instruction SQL dans un fichier texte nomm
lab_05_04.sql.
M
o
h
a
m
e
d

G
h
e
n
n
o
u

(
g
h
e
n
n
o
u
m
@
y
a
h
o
o

f
r
)

h
a
s

a

n
o
n
-
t
r
a
n
s
f
e
r
a
b
l
e
a
mmm
eeeeeeeee
dddddddddd

GGGGGGGGG
hhhhhh
eeeeeeee
nnnnnnnn
nnnnnnnn
o
uuuuuuuu

((((((((
gggggggg
hhhhhhh
eeeeeee
nnnnnnnnnnn
nnnn
oooo
uuuuuuuu
mmmmmmmm
@@@@@@@@@@@
yyyyyyyyyyy
aaaaaaaaaaa
hhhhhhhhhhh
ooooooooo
oooooooooo

fffffffffff
rrrrrr
))))))))

hhhhhhhh
aaaaaaaa
ssssssss

aaaaaaa

nnnnnnnn
ooooooo
nnnnnnnn
-
tttttttt
rrrrrrrr
aaaaaaaa
n
ssssssss
ffffffff
eeeeeeeeee
rrrrrr
aaaaaaaaa
bbbbbbbb
lllllll
iiiiiii
ccccccc
eeee
nnnnnn
ssssssss
eeeeeeee

tttttt
ooooooooo

uuuuuuuu
ssssssss
e

ttttttt
hhhhhhh
iiiiiii
sssssss

SSSSSSSSSSSSS
ttttttttttttt
uuuuuuuuuu
dddddddd
eeeeeeeee
nnnnnnnnnn
tttttttttt

GGGGGGGG
uuuuuuu
iiiiiiii
dddddddd
eeee

Unauthorized reproduction or distribution prohibited Copyright 2009, Oracle and/or its affiliates thorized reproduction or distribution prohibited Copyright 2009, Oracle and/or its aff thorized reproduction or distribution prohibited Copyright 2009, Oracle and/or its affi
O l D t b 10 : Les fondamentaux du langage SQL (I) 5 32
Oracle Database 10g : Les fondamentaux du langage SQL (I) 5-33
Exercice 5 (suite)
5. Modifiez le fichier lab_05_04.sql afin d'afficher tous les employs dont King, qui
n'a pas de manager. Triez les rsultats par numro d'employ. Placez l'instruction SQL
dans un fichier texte nomm lab_05_05.sql. Excutez l'interrogation du script
lab_05_05.sql.
6. Crez un tat pour le dpartement HR, qui affiche le nom de famille et le numro de
dpartement de tous les employs qui travaillent dans le mme dpartement qu'un
employ donn. Affectez chaque colonne le libell appropri. Enregistrez le script dans
un fichier nomm lab_05_06.sql.

M
o
h
a
m
e
d

G
h
e
n
n
o
u

(
g
h
e
n
n
o
u
m
@
y
a
h
o
o

f
r
)

h
a
s

a

n
o
n
-
t
r
a
n
s
f
e
r
a
b
l
e
t le num
e dpartem
appropri. E
a
n
s
f
e
r
a
mmmmmmmmmm
eeeeeeee
dddd

GGGGGGGG
hhhhhhhh
eeee
nnnnnn
nnnnnnnn
oooooooo
uuuu

((((((((
gggggggg
hhhhhhhh
eeeeee
nnnnnnnnn
nnnnnnnnnnn
oooooooooo
uuuuuu
mmmmmmm
@@@@@@@@@@@
yyyyyyyyyyy
aaaaaaaaaaaaa
hhhhhhhhhhhh
ooooooooo
o
G
u
i
d
e

llllll
iiiiii
cccccccc
eeeeeeee
nnnnnnnn
s
eeeeeee

tttttttttt
oooooooooo

uuuuuuuuu
ssssssssss
eeeeeeeeee

ttttttt
hhhhhhhhhh
iiiiiiii
ssssssss

SSSSSSSS
tttt
uuuuu
dddddddd
eeeeeee
n
ttttttttt

GGGGGGGGGGG
uuuu
i
Unauthorized reproduction or distribution prohibited Copyright 2009, Oracle and/or its affiliates thorized reproduction or distribution prohibited Copyright 2009, Oracle and/or its aff thorized reproduction or distribution prohibited Copyright 2009, Oracle and/or its affi
O l D t b 10 : Les fondamentaux du langage SQL (I) 5 33
Oracle Database 10g : Les fondamentaux du langage SQL (I) 5-34
Exercice 5 (suite)
7. Le dpartement HR a besoin d'un tat sur les niveaux de poste et les salaires. Pour vous
familiariser avec la table JOB_GRADES, commencez par en afficher la structure. Crez
ensuite une interrogation qui affiche le nom, le poste, le nom du dpartement, le salaire et
le niveau de tous les employs.
Si vous souhaitez tester vos connaissances de manire plus approfondie, effectuez les exercices
suivants :
8. Le dpartement HR souhaite dterminer le nom de tous les employs qui ont t
embauchs aprs Davies. Crez une interrogation permettant d'afficher le nom et la date
d'embauche de ces employs.

M
o
h
a
m
e
d

G
h
e
n
n
o
u

(
g
h
e
n
n
o
u
m
@
y
a
aissances
nt HR souh
uchs aprs
d'embauch
o
o
f
r
)

h
a
s

a

n
o
n
-
t
r
a
n
s
f
e
r
a
b
l
e
))))))
hhhhhhhh
aaaaaaaa
ssssssss

aaaaaaaa

nnnnnnn
oooooo
nnnn
---
tttttttttt
rrrrrrrrrr
aaaaaaaaaa
nnnnnnnnn
ssssssssss
ffffffff
eeeeeeee
rrrr
aaaaaaaa
b
@
y
a
h
o
o

f
)
m
ee
l
i
c
e
n
s
e

t
o

u
s
e

t
h
i
s

S
t
u
d
e
n
t

de manire
haite dterm
Davies. Cr
e ces em
G
u
i
d
e

d
e
n
t
G
u
i
d
e
Unauthorized reproduction or distribution prohibited Copyright 2009, Oracle and/or its affiliates thorized reproduction or distribution prohibited Copyright 2009, Oracle and/or its aff thorized reproduction or distribution prohibited Copyright 2009, Oracle and/or its affi
O l D t b 10 : Les fondamentaux du langage SQL (I) 5 34
Oracle Database 10g : Les fondamentaux du langage SQL (I) 5-35
Exercice 5 (suite)
9. Le dpartement HR a besoin de dterminer le nom et la date d'embauche de tous les
employs qui ont t embauchs avant leur manager, ainsi que le nom et la date
d'embauche de leur manager. Enregistrez le script dans un fichier
nomm lab_5_09.sql.
M
o
h
a
m
e
d

G
h
e
n
n
o
u

(
g
h
e
n
n
o
u
m
@
y
a
h
o
o

f
r
)

h
a
s

a

n
o
n
-
t
r
a
n
s
f
e
r
a
b
l
e
a
n
o
n
-
t
r
aaaaaa
nnnnnnnn
ssssssss
ffff
e
rrrrrrrr
aaaaaaaaa
bbbbbb
l
i
c
e
n
s
e

t
o

u
s
e

t
h
i
s

S
t
u
d
e
n
t

G
u
i
d
e

Unauthorized reproduction or distribution prohibited Copyright 2009, Oracle and/or its affiliates thorized reproduction or distribution prohibited Copyright 2009, Oracle and/or its aff thorized reproduction or distribution prohibited Copyright 2009, Oracle and/or its affi
O l D t b 10 : Les fondamentaux du langage SQL (I) 5 35

Das könnte Ihnen auch gefallen