diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2015-11-14 01:29:11 +0000 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2015-11-14 01:29:11 +0000 |
commit | f9ff726137004a78dda390167c8b81ecbcfaae24 (patch) | |
tree | 489a540eb58d9c82f8484da3f81d1e7a728ea442 /ws2015/dbs/blaetter | |
parent | bdc3e65ec0e93da5499b1ff7486eea5775fdd73a (diff) | |
download | uni-f9ff726137004a78dda390167c8b81ecbcfaae24.tar uni-f9ff726137004a78dda390167c8b81ecbcfaae24.tar.gz uni-f9ff726137004a78dda390167c8b81ecbcfaae24.tar.bz2 uni-f9ff726137004a78dda390167c8b81ecbcfaae24.tar.xz uni-f9ff726137004a78dda390167c8b81ecbcfaae24.zip |
dbs 05
Diffstat (limited to 'ws2015/dbs/blaetter')
-rw-r--r-- | ws2015/dbs/blaetter/05/abgabe.md | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/ws2015/dbs/blaetter/05/abgabe.md b/ws2015/dbs/blaetter/05/abgabe.md new file mode 100644 index 0000000..046a270 --- /dev/null +++ b/ws2015/dbs/blaetter/05/abgabe.md | |||
@@ -0,0 +1,52 @@ | |||
1 | --- | ||
2 | header-includes: | ||
3 | - \lstset{frame=single, breaklines=true, postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}}} | ||
4 | --- | ||
5 | |||
6 | # Anfragen in SQL | ||
7 | |||
8 | a) | ||
9 | |||
10 | ~~~ {.sql .numberLines} | ||
11 | SELECT pname FROM P WHERE ort = "Berlin" | ||
12 | ~~~ | ||
13 | b) | ||
14 | |||
15 | ~~~ {.sql .numberLines} | ||
16 | SELECT T.tnr FROM T, L, LTP WHERE LTP.tnr = T.tnr AND LTP.lnr = L.lnr AND L.lname = "Meier" | ||
17 | ~~~ | ||
18 | c) | ||
19 | |||
20 | ~~~ {.sql .numberLines} | ||
21 | SELECT T.farbe FROM T, P, LTP WHERE LTP.pnr = P.pnr AND LTP.tnr = T.tnr AND P.ort = "Berlin" | ||
22 | ~~~ | ||
23 | d) Ich nehme hier und im folgenden an, dass mit *P2* und *P3* die Projekte mit Nummer 2 und 3 gemeint sind---sind *P2* und *P3* Namen ist die Lösung komplett analog. | ||
24 | |||
25 | ~~~ {.sql .numberLines} | ||
26 | SELECT T.name, T.farbe FROM T, P, LTP \ | ||
27 | WHERE LTP.pnr = P.pnr AND LTP.tnr = T.tnr AND ( P.pnr = 2 OR P.pnr = 3 ) | ||
28 | ~~~ | ||
29 | |||
30 | |||
31 | # Änderungsoperationen in SQL | ||
32 | |||
33 | a) | ||
34 | |||
35 | ~~~ {.sql .numberLines} | ||
36 | INSERT INTO L (lname, status, sitz) VALUES ("Maier", 10, "Neuried"); | ||
37 | INSERT INTO LTP (lnr, tnr, pnr, menge) SELECT lnr, 4 as tnr, 8 as pnr, 200 as menge FROM L WHERE lname = "Maier"; -- lname ist schlüsselkanidat; ansonsten muss Datenbankspezifische Funktionalität genutzt werden um lnr zu ermitteln. | ||
38 | COMMIT; | ||
39 | ~~~ | ||
40 | b) | ||
41 | |||
42 | ~~~ {.sql .numberLines} | ||
43 | UPDATE LTP SET menge = menge * 3 WHERE pnr = 4; | ||
44 | COMMIT; | ||
45 | ~~~ | ||
46 | c) | ||
47 | |||
48 | ~~~ {.sql .numberLines} | ||
49 | DELETE FROM LTP WHERE lnr = 4; | ||
50 | DELETE FROM L WHERE lnr = 4; | ||
51 | COMMIT; | ||
52 | ~~~ | ||