Als pdf oder txt herunterladen
Als pdf oder txt herunterladen
Sie sind auf Seite 1von 57

Einstieg in SQL 3rd Edition Michael

Laube
Visit to download the full and correct content document:
https://ebookstep.com/product/einstieg-in-sql-3rd-edition-michael-laube/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Einstieg in SQL 3rd Edition Michael Laube

https://ebookstep.com/product/einstieg-in-sql-3rd-edition-
michael-laube/

R kompakt Der schnelle Einstieg in die Datenanalyse 3rd


Edition Daniel Wollschläger

https://ebookstep.com/product/r-kompakt-der-schnelle-einstieg-in-
die-datenanalyse-3rd-edition-daniel-wollschlager/

Arduino für Kids Der einfache Einstieg in die Welt der


Mikrocontroller Programmierung 3rd Edition Erik
Schernich

https://ebookstep.com/product/arduino-fur-kids-der-einfache-
einstieg-in-die-welt-der-mikrocontroller-programmierung-3rd-
edition-erik-schernich/

Datenbanken und SQL Eine praxisorientierte Einführung


mit Anwendungen in Oracle SQL Server und MySQL 5th
Edition Edwin Schicker

https://ebookstep.com/product/datenbanken-und-sql-eine-
praxisorientierte-einfuhrung-mit-anwendungen-in-oracle-sql-
server-und-mysql-5th-edition-edwin-schicker/
Einstieg in Lightroom 6 und CC Torsten Kieslich

https://ebookstep.com/product/einstieg-in-lightroom-6-und-cc-
torsten-kieslich/

SQL Der Grundkurs für Ausbildung und Praxis Mit


Beispielen in MySQL MariaDB PostgreSQL und T SQL 4th
Edition Ralf Adams

https://ebookstep.com/product/sql-der-grundkurs-fur-ausbildung-
und-praxis-mit-beispielen-in-mysql-mariadb-postgresql-und-t-
sql-4th-edition-ralf-adams/

R kompakt Der schnelle Einstieg in die Datenanalyse


German Edition Daniel Wollschläger

https://ebookstep.com/product/r-kompakt-der-schnelle-einstieg-in-
die-datenanalyse-german-edition-daniel-wollschlager/

Dansen in de hemel 1st Edition Michael Pilarczyk

https://ebookstep.com/product/dansen-in-de-hemel-1st-edition-
michael-pilarczyk/

Algorithmen in der Graphentheorie Ein konstruktiver


Einstieg in die Diskrete Mathematik 1st Edition Katja
Mönius Jörn Steuding Pascal Stumpf

https://ebookstep.com/product/algorithmen-in-der-graphentheorie-
ein-konstruktiver-einstieg-in-die-diskrete-mathematik-1st-
edition-katja-monius-jorn-steuding-pascal-stumpf/
Michael Laube
Einstieg in SQL

3., aktualisierte Auflage 2022


Impressum

Dieses E-Book ist ein Verlagsprodukt, an dem viele mitgewirkt


haben, insbesondere:
Lektorat Christoph Meister
Korrektorat Petra Biedermann, Reken
Covergestaltung Silke Braun
Herstellung E-Book Maxi Beithe
Satz E-Book Typographie & Computer, Krefeld
Bibliografische Information der Deutschen Nationalbibliothek:
Die Deutsche Nationalbibliothek verzeichnet diese Publikation in
der Deutschen Nationalbibliografie; detaillierte bibliografische
Daten sind im Internet über http://dnb.dnb.de abrufbar.
ISBN 978-3-8362-8817-0
3., aktualisierte Auflage 2022
© Rheinwerk Verlag GmbH, Bonn 2022
Liebe Leserin, lieber Leser,

Sie haben sicherlich schon einmal mit einer relationalen Datenbank


und SQL zu tun gehabt. Denn egal ob bei der Webentwicklung, der
Programmierung oder der Systemadministration: Überall, wo große
Datenmengen verarbeitet werden, werkelt ganz sicher eine
Datenbank im Hintergrund. Eine zentrale Rolle spielt dabei die
Structured Query Language und ihre verschiedenen Dialekte, die seit
Jahrzehnten bei der Arbeit mit Datenbanken eingesetzt werden.
Daher ist es eine sehr gute Entscheidung, sich mit SQL, der richtigen
Datenverarbeitung und der korrekten Datenmodellierung zu
beschäftigen, denn dieses Wissen wird Ihnen in vielen Bereichen
weiterhelfen.
Dabei steht Ihnen Michael Laube zur Seite, der als erfahrener
Datenbankentwickler schon lange mit SQL arbeitet. Er erklärt Ihnen
schrittweise und detailliert, wie Sie die Beispieldatenbank auf Ihrem
Rechner einrichten, Rohdaten von Redundanzen befreien und
effiziente Abfragen formulieren. Übungen und Musterlösungen aus
der Praxis runden das Angebot ab und sorgen dafür, dass Ihnen die
Syntax der Befehle leicht von der Hand geht und dass Ihnen auch
große Datenmengen keine Probleme bereiten. So ist dieser
Leitfaden ideal für das Selbststudium, die Lehre oder für den
täglichen Einsatz in der Praxis geeignet.
Um die Qualität unserer Bücher zu gewährleisten, stellen wir stets
hohe Ansprüche an Autoren und Lektorat. Sollten Sie dennoch
Fehler finden oder inhaltliche Anregungen haben, scheuen Sie sich
nicht, mit mir Kontakt aufzunehmen. Ihre Fragen und
Änderungsvorschläge sind jederzeit willkommen.
Ihr Christoph Meister
Lektorat Rheinwerk Computing
[email protected]
www.rheinwerk-verlag.de
Rheinwerk Verlag • Rheinwerkallee 4 • 53227 Bonn
Inhaltsverzeichnis

Aus dem Lektorat


Inhaltsverzeichnis

Materialien zum Buch

1 Grundlagen kennenlernen und


verstehen
1.1 Die Tabelle als zentrales Element
1.1.1 Tabellen und ihre Struktur
1.2 Eine kleine Historie von SQL
1.3 Datenbanksysteme
1.4 SQL – ein Standard und seine Umsetzung
1.5 Zu diesem Buch
1.6 MySQL unter Windows installieren
1.7 Die MySQL-Übungsdatenbank anlegen
1.8 Eine erste Abfrage an die Datenbank senden
1.9 Kommentarfunktion
1.9.1 Kommentare in der Praxis nutzen
1.9.2 Übungen

2 Los geht’s: Die


Grundfunktionen der
Tabellenabfrage (SELECT)
2.1 Mit einer SELECT-Anweisung Tabellen abfragen
2.1.1 Die Tabelle »mitarbeiter«
2.1.2 Wie frage ich eine Tabelle ab? (SELECT ...
FROM)
2.1.3 Spalten einer Tabelle abfragen
2.1.4 Alle Spalten einer Tabelle abfragen
2.1.5 Übungen
2.2 Zeilen in einer Abfrage mit WHERE filtern
2.2.1 SQL-Vergleichsoperatoren
2.2.2 Spaltenwerte auf Gleichheit prüfen
2.2.3 Spaltenwerte auf Ungleichheit prüfen
2.2.4 Spaltenwerte auf kleiner als/gleich prüfen
2.2.5 Spaltenwerte auf größer als/gleich prüfen
2.2.6 Bedingungen mit dem NOT-Operator
verneinen
2.2.7 Spaltenwerte auf ein Intervall prüfen
(BETWEEN)
2.2.8 Spaltenwerte auf ein Muster prüfen (LIKE)
2.2.9 Spaltenwerte auf Mengenzugehörigkeit
prüfen
2.2.10 Fehlende Spaltenwerte (NULL-Value)
2.2.11 Spaltenwerte auf NULL prüfen
2.2.12 Spaltenwerte auf »ist nicht NULL« prüfen
2.2.13 Spaltenwerte mit Spaltenwerten
vergleichen
2.2.14 Übungen
2.3 Filterbedingungen mit AND (NOT) und OR
(NOT) logisch verknüpfen
2.3.1 Der logische Verknüpfungsoperator AND
2.3.2 SQL-Bedingungen mit dem logischen AND-
Operator verknüpfen
2.3.3 Der logische Verknüpfungsoperator OR
2.3.4 SQL-Bedingungen mit dem logischen OR-
Operator verknüpfen
2.3.5 Der logische Verknüpfungsoperator AND
NOT
2.3.6 SQL-Bedingungen mit dem AND NOT-
Operator logisch verknüpfen
2.3.7 Der logische Verknüpfungsoperator OR
NOT
2.3.8 SQL-Bedingungen mit dem logischen OR
NOT-Operator verknüpfen
2.3.9 Logische Verknüpfungsoperatoren
kombiniert anwenden
2.3.10 Übungen
2.4 Ergebniszeilen einer SELECT-Anweisung
einschränken
2.4.1 Ergebniszeilen mit FETCH, LIMIT und TOP
eingrenzen
2.4.2 Übungen
2.5 Datensätze sortiert abfragen
2.5.1 Aufsteigende Sortierung gemäß einer
Spaltenangabe
2.5.2 Auf- und absteigende Sortierung mehrerer
Spalten
2.5.3 Nach numerischen Spaltenwerten sortieren
2.5.4 Nach Datumswerten sortieren
2.5.5 Nicht definierte Werte in einer Sortierung
beachten
2.5.6 ORDER BY mit einer WHERE-Klausel
verwenden
2.5.7 Übungen
2.6 Konstanten in die Spaltenauswahlliste
aufnehmen
2.6.1 Abfrage eines konstanten Textes
2.6.2 Konstanten und Spalten einer Tabelle
gleichzeitig abfragen
2.6.3 Übungen
2.7 Spalten einen Alias zuordnen
2.7.1 Spalten in einer Abfrage mit einem Alias
versehen
2.7.2 Ausgewählten Spalten einer Abfrage einen
Alias zuordnen
2.7.3 Spalten und Konstanten einen Alias
zuordnen
2.7.4 Übungen
2.8 Gleiche Ergebniszeilen ausschließen (DISTINCT)
2.8.1 Übungen

3 Zeilen einfügen (INSERT),


ändern (UPDATE) und löschen
(DELETE, TRUNCATE)
3.1 Zeilen mit einer INSERT-Anweisung einfügen
3.1.1 Spaltenwerte mit expliziter Spaltenangabe
einfügen
3.1.2 Spaltenwerte ohne Spaltenangabe einfügen
3.1.3 Übungen
3.2 Zeilen mit einer UPDATE-Anweisung ändern
3.2.1 Einen Spaltenwert einer Zeile ändern
3.2.2 Mehrere Spaltenwerte einer Zeile
gleichzeitig ändern
3.2.3 Spaltenwerte einer Spalte für mehrere
Zeilen gleichzeitig ändern
3.2.4 Allen Spaltenwerten einer Spalte einen
Wert zuordnen
3.2.5 Spaltenwerten mit einer UPDATE-
Anweisung einen NULL-Wert zuweisen
3.2.6 Schlüsselwertspalten mit UPDATE einen
neuen Wert zuweisen
3.2.7 Übungen
3.3 Zeilen mit einer DELETE-Anweisung löschen
3.3.1 Eine Zeile einer Tabelle löschen
3.3.2 Mehrere Zeilen einer Tabelle gleichzeitig
löschen
3.3.3 Alle Zeilen einer Tabelle gleichzeitig löschen
3.3.4 Übungen
3.4 Alle Zeilen einer Tabelle mit einer TRUNCATE-
Anweisung löschen
3.4.1 Die TRUNCATE-Anweisung anwenden
3.4.2 Übungen zum Thema »Alle Zeilen einer
Tabelle mit einer TRUNCATE-Anweisung löschen«

4 Tabellen anlegen (CREATE


TABLE)
4.1 Datentypen
4.1.1 Datentypen für ganze Zahlen
4.1.2 Datentypen für rationale Zahlen
4.1.3 Datentypen für Datum und Zeit
4.1.4 Datentypen für Zeichenketten
4.1.5 Übungen
4.2 Datentypen umwandeln
4.3 Explizite und implizite Typkonvertierung
4.3.1 Explizite Typkonvertierung
4.3.2 Implizite Typkonvertierung
4.3.3 Übungen
4.4 Einfache Tabellen mit CREATE TABLE erstellen
4.4.1 Zielstruktur der Tabelle
4.4.2 Tabellen mit der CREATE TABLE-Anweisung
anlegen
4.4.3 Tabellen mit einer DROP-Anweisung
löschen
4.4.4 Eine Tabelle mit einem Primärschlüssel
ausstatten
4.4.5 Automatisch hochzählende numerische
Primärschlüsselspalten festlegen
4.4.6 Reservierte Schlüsselwörter
4.4.7 Übungen
4.5 Spalten Einschränkungen (CONSTRAINTS)
zuordnen
4.5.1 Spalten als Pflichtfelder (NOT NULL)
definieren
4.5.2 Spalten mit einer UNIQUE-Einschränkung
versehen
4.5.3 Standardwerte mit DEFAULT für Spalten
festlegen
4.5.4 Bedingungen mit einer CHECK-
Einschränkung für Spalten festlegen
4.5.5 Übungen
4.6 Spalten auf Tabellenebene Einschränkungen
(CONSTRAINT) zuordnen
4.6.1 Einen Primärschlüssel auf Tabellenebene
festlegen
4.6.2 Eine UNIQUE-Einschränkung auf
Tabellenebene festlegen
4.6.3 Eine CHECK-Einschränkung auf
Tabellenebene festlegen
4.6.4 Übungen

5 Mengenoperationen anwenden
5.1 Mengenoperationen auf Ergebnistabellen
anwenden
5.1.1 Eine Vereinigungsmenge aus zwei Mengen
bilden
5.1.2 Eine Schnittmenge bilden
5.1.3 Eine Differenzmenge bilden
5.2 Eine Vereinigungsmenge bilden (UNION)
5.2.1 Vereinigungsmengen von Ergebnistabellen
bilden
5.2.2 Übungen
5.3 Die Schnittmenge von Ergebnistabellen bilden
(INTERSECT)
5.3.1 Schnittmengen von Ergebnistabellen
5.3.2 Übungen
5.4 Eine Differenzmenge aus Ergebnistabellen
bilden (EXCEPT)
5.4.1 Differenzmenge von Ergebnismengen
bilden
5.4.2 Übungen
5.5 Mengenoperationen in Kombination mit einer
WHERE-Klausel verwenden
5.5.1 Vor einer Vereinigungsoperation mit UNION
filtern
5.5.2 Übung
5.6 Vereinigungsmengen in Kombination mit einer
ORDER BY-Klausel
5.6.1 Übungen
6 Benutzer, Rollen und ihre
Berechtigungen
6.1 Benutzer anlegen (CREATE USER)
6.1.1 Nutzer in einer MySQL- oder MariaDB-
Datenbank anlegen
6.1.2 Nutzer in einer PostgreSQL-Datenbank
anlegen
6.1.3 Nutzer in einer MS SQL Server-Datenbank
anlegen
6.2 Benutzer entfernen
6.3 Eine Verbindung für einen Datenbankbenutzer
erstellen
6.3.1 Verbindung für eine MySQL-Datenbank
einrichten
6.3.2 Verbindung für eine MariaDB-Datenbank
herstellen
6.3.3 Verbindung für eine PostgreSQL-Datenbank
herstellen
6.3.4 Verbindung für eine MS SQL Server-
Datenbank herstellen
6.4 Berechtigungen verwalten
6.4.1 Berechtigungen vergeben (GRANT)
6.4.2 Berechtigungen entziehen (REVOKE)
6.5 Mit Rollen Berechtigungen zuordnen
6.5.1 Rollen anlegen (CREATE ROLE)
6.5.2 Rollen mit Berechtigungen ausstatten
6.5.3 Rollen Datenbanknutzern zuordnen
6.5.4 Rollen Berechtigungen entziehen
6.5.5 Rollen entfernen
6.6 Übungen
6.7 Lösungen zu den Übungen

7 Datenbanken modellieren
7.1 Anforderungskatalog
7.2 Entitäten identifizieren und modellhaft abbilden
7.2.1 Entitäten identifizieren
7.2.2 Informationen zu den Entitäten ermitteln
7.2.3 Schlüsselattribute für Entitäten
identifizieren
7.2.4 Die Wertebereiche von Attributen erkennen
7.2.5 Zwischen Pflichtattributen und optionalen
Attributen unterscheiden
7.3 Beziehungen zwischen Entitäten festlegen
7.3.1 Beziehungen im Entity-Relationship-Modell
definieren
7.3.2 Kardinalitäten von Beziehungen erkennen
7.3.3 Eine besondere 1:n-Beziehung – oder
Entitäten, die auf sich selbst verweisen
7.3.4 Starke und schwache Entitäten
unterscheiden
7.4 Datenmodelle in der UML-Notation darstellen
7.5 Übungen

8 Datenmodelle optimieren
(Normalisierung)
8.1 Redundanzen erkennen
8.1.1 Was ist eine Redundanz?
8.1.2 Was bedeutet Normalisierung?
8.2 Die 1. Normalform anwenden
8.3 Die 2. Normalform anwenden
8.4 Die 3. Normalform anwenden
8.5 Denormalisierung
8.6 Übungen

9 Datenmodelle in Tabellen
überführen
9.1 Die Ausbildungsdatenbank anlegen
9.1.1 Eine neue Datenbank mit UTF-8-
Zeichensatz anlegen (MySQL, MariaDB)
9.1.2 Eine neue Datenbank mit UTF-8-
Zeichensatz anlegen (PostgreSQL)
9.1.3 Eine neue Datenbank mit Unicode-
Zeichensatz anlegen (MS SQL Server)
9.1.4 Übung
9.2 Tabellen mit Beziehungen zu anderen Tabellen
erstellen
9.2.1 Die Ausbildungsdatenbank im Modell
erfassen
9.2.2 Tabellen erstellen, die in einer 1:1-
Beziehung stehen
9.2.3 Tabellen erstellen, die in einer 1:n-
Beziehung stehen
9.2.4 Tabellen erstellen, die in einer m:n-
Beziehung stehen
9.2.5 Tabellen erstellen, die zu sich selbst in
Beziehung stehen
9.3 Übung
9.4 Die referenzielle Integrität verstehen

10 Operationen auf Tabellen in


Beziehungen anwenden
10.1 Zeilen in Tabellen einfügen, die in Beziehung
zueinander stehen
10.1.1 Zeilen in die Tabelle »auszubildender«
einfügen
10.1.2 Zeilen in die Tabelle »ausbildungsberuf«
einfügen
10.1.3 Zeilen in die Tabelle »lehrfach« einfügen
10.1.4 Zeilen in die Tabelle »adresse« (inklusive
der Beziehungen) einfügen
10.1.5 Zeilen in die Tabelle »ausbildungsvertrag«
(inklusive der Beziehungen) einfügen
10.1.6 Zeilen in die Tabelle »beruflehrfach«
(inklusive der Beziehungen) einfügen
10.1.7 Zeilen in die Tabelle
»mitarbeiterausbildungsbetrieb« (inklusive der
Beziehungen) einfügen
10.1.8 Übungen
10.2 Zeilen aus Tabellen, die in Beziehung stehen,
mit JOIN verbunden abfragen
10.2.1 Zeilen mit einem INNER JOIN verbinden
10.2.2 Zeilen mit einem LEFT OUTER JOIN
verbinden
10.2.3 Zeilen mit einem RIGHT OUTER JOIN
verbinden
10.2.4 Zeilen mit einem FULL OUTER JOIN
verbinden
10.2.5 Einen FULL OUTER JOIN unter MySQL
oder MariaDB nachbilden
10.2.6 Zeilen mit einem CROSS JOIN verbinden
10.2.7 Zeilen von drei Tabellen mit einem INNER
JOIN verbinden
10.2.8 Spalten in einem JOIN über
Tabellennamen referenzieren
10.2.9 Spalten in einem JOIN über
Tabellenaliasse referenzieren
10.2.10 Zeilen mit einem Self Join verbinden
10.2.11 Zeilen mit einem INNER JOIN ohne
Schlüsselvergleich verbinden
10.2.12 Übungen
10.3 Beziehungen (Schlüsselbeziehungen) ändern
10.3.1 Beziehungen aus Zeilen aus einer
Kindtabelle ändern
10.3.2 Beziehungen aus Zeilen einer Elterntabelle
ändern (ON UPDATE CASCADE)
10.3.3 Übungen
10.4 Beziehungen (Schlüsselbeziehungen) aufheben
oder löschen
10.4.1 Zeilen aus Kindtabellen auf NULL setzen
10.4.2 Zeilen aus Kindtabellen löschen
10.4.3 Zeilen aus Elterntabellen löschen
10.4.4 Übungen
11 Transaktionen
11.1 Forderungen an relationale Datenbanksysteme
11.2 Transaktionen verstehen
11.2.1 Allgemeiner Aufbau einer Transaktion
11.2.2 Einen atomaren Datenzustand mit
Transaktionen sicherstellen
11.2.3 Transaktionen mit ROLLBACK rückgängig
machen
11.2.4 Operationen mit Transaktionen isoliert
ausführen
11.3 Übungen

12 Tabellenstrukturen verändern
12.1 Eine Tabelle umbenennen
12.2 Spalten einer Tabelle ändern
12.2.1 Eine Spalte umbenennen
12.2.2 Den Datentyp einer Spalte ändern
12.2.3 Eine Spalte als Primärschlüsselspalte
definieren
12.2.4 Einer Spalte eine NOT NULL-
Einschränkung zuordnen
12.2.5 Einer Spalte eine NULL-Einschränkung
zuordnen
12.2.6 Einer Spalte einen Standardwert
(DEFAULT VALUE) zuordnen
12.2.7 Einer Spalte eine UNIQUE-Einschränkung
zuordnen
12.2.8 Eine Spalte mit einer CHECK-
Einschränkung versehen
12.3 Spalten hinzufügen und entfernen
12.3.1 Einer Tabelle eine Spalte hinzufügen
12.3.2 Eine Spalte aus einer Tabelle entfernen
12.4 Beziehungen zwischen Tabellen herstellen und
entfernen
12.5 Übungen

13 Mit SQL rechnen


13.1 Spaltenwerte addieren
13.2 Spaltenwerte subtrahieren
13.3 Spaltenwerte multiplizieren
13.4 Spaltenwerte dividieren
13.5 Den Restwert einer Division von Spaltenwerten
berechnen
13.6 Nach dem Ergebnis einer Berechnung filtern
13.7 Nach dem Ergebnis einer Berechnung
sortieren lassen
13.8 Übungen

14 Skalarfunktionen anwenden
14.1 Funktionen für Textwerte
14.1.1 Zeichenkette in Kleinbuchstaben
umwandeln (LOWER)
14.1.2 Spaltenwerte in Großbuchstaben
umwandeln (UPPER)
14.1.3 Spaltenwerte von führenden und
endenden Leerzeichen befreien (TRIM)
14.1.4 Text aus Spaltenwerten extrahieren
(SUBSTRING)
14.1.5 Textspaltenwerte verkettet ausgeben
14.1.6 Übungen
14.2 Funktionen für Zahlenwerte
14.2.1 Die Länge einer Zeichenkette ermitteln
(CHAR_LENGTH, LEN)
14.2.2 Die Startposition einer Zeichenkette in
einem Textwert ermitteln (POSITION,
CHARINDEX)
14.2.3 Potenzen berechnen (POWER)
14.2.4 Eine Quadratwurzel berechnen (SQRT)
14.2.5 Übungen
14.3 Verschachtelte Funktionsaufrufe
14.3.1 Übungen

15 Bedingungslogik
15.1 Die CASE-Klausel
15.2 Bedingungslogik in einer Spaltenauswahlliste
einer SELECT-Anweisung anwenden
15.3 Bedingungslogik in einer ORDER BY-Klausel
anwenden
15.4 Übungen

16 Mit Zeit und Datum arbeiten


16.1 Datumsformate
16.2 Skalarfunktionen für Zeit- und Datumsangaben
in SQL nutzen
16.2.1 Datum, Zeit und Zeitstempel vom
Datenbankserver ermitteln lassen
16.2.2 Ergebnislisten mit einem Berichtsdatum
versehen
16.2.3 Übungen
16.3 Zeit- und Datumsangaben formatieren
16.3.1 Datumsformatierung unter MySQL und
MariaDB (DATE_FORMAT)
16.3.2 Datumsformatierung unter PostgreSQL
(TO_CHAR)
16.3.3 Datumsformatierung unter MS SQL Server
(FORMAT)
16.3.4 Übungen
16.4 Datumsangaben extrahieren (EXTRACT)
16.4.1 Übungen
16.5 Mit Datumsangaben rechnen
16.5.1 Mit Datumswerten rechnen unter MySQL
und MariaDB
16.5.2 Mit Datumswerten rechnen unter
PostgreSQL
16.5.3 Mit Datumswerten rechnen unter MS SQL
Server
16.5.4 Übungen

17 Spaltenwerte gruppieren
(GROUP BY)
17.1 Die Aggregatfunktion COUNT anwenden
17.1.1 Übungen
17.2 Die Aggregatfunktion SUM anwenden
17.2.1 Übungen
17.3 Die Aggregatfunktion AVG anwenden
17.3.1 Übungen
17.4 Die Aggregatfunktion MAX anwenden
17.4.1 Übungen
17.5 NULL-Werte berücksichtigen
17.5.1 Übungen
17.6 Nach aggregierten Werten einer Gruppierung
filtern (HAVING)
17.6.1 Übungen
17.7 Nach zwei oder mehr Spalten gruppieren
17.7.1 Übungen

18 Mächtiges Werkzeug: Die


Unterabfragen (Subqueries)
18.1 Unterabfragen, die in Korrelation zueinander
stehen
18.1.1 Übungen
18.2 Unterabfragen, die nicht in Korrelation
zueinander stehen
18.2.1 Übungen
18.3 Vergleichsoperatoren auf Unterabfragen mit
ANY, SOME und ALL anwenden
18.3.1 Übungen
18.4 Auf die Existenz von Ergebniszeilen aus
Unterabfragen prüfen (EXISTS)
18.4.1 Übungen

19 Views: Abfragen in virtuellen


Tabellen speichern
19.1 Einfache Views anlegen
19.1.1 Übungen
19.2 Views und ORDER BY
19.2.1 Übungen
19.3 INSERT, UPDATE und DELETE auf Views
anwenden
19.3.1 Eine INSERT-Anweisung auf Views
anwenden
19.3.2 Eine UPDATE-Anweisung auf Views
anwenden
19.3.3 Eine DELETE-Anweisung auf Views
anwenden
19.3.4 Views, auf die keine INSERT-, DELETE-
oder UPDATE-Anweisung angewendet werden
kann
19.3.5 Übungen
19.4 Views entfernen oder ersetzen
19.4.1 Übungen

20 Abfragen mit einem Index


optimieren
20.1 Einführung
20.2 Syntax: Index erstellen
20.3 Eine Tabelle mit vielen Zeilen generieren
20.4 Einen Index für eine Tabelle anlegen
20.5 Einen Index über mehrere Spalten anlegen
20.6 Den Index einer Tabelle löschen
20.7 Fremdschlüsselspalten indexieren
20.8 Übungen

Stichwortverzeichnis
Rechtliche Hinweise
Über den Autor
Materialien zum Buch

Auf der Webseite zu diesem Buch stehen folgende Materialien für


Sie zum Download bereit:
alle Beispieldatenbanken für MySQL, MariaDB, Microsoft SQL
Server sowie PostgreSQL
Installationsanleitungen für MariaDB, Microsoft SQL Server und
PostgreSQL
Gehen Sie auf www.rheinwerk-verlag.de/5458. Klicken Sie auf den
Reiter Materialien zum Buch. Sie sehen die herunterladbaren Dateien
samt einer Kurzbeschreibung des Dateiinhalts. Klicken Sie auf den
Button Herunterladen, um den Download zu starten. Je nach Größe
der Datei (und Ihrer Internetverbindung) kann es einige Zeit dauern,
bis der Download abgeschlossen ist.
Ich danke allen in meinem privaten Umfeld, die mich während der
Erstellung des Buches so umfangreich unterstützt haben und mir
auch in schwierigen Phasen beigestanden haben.
An dieser Stelle möchte ich mich bei allen Mitwirkenden des Verlags
für die gute Zusammenarbeit bedanken. Mein Dank gilt Korrektorin
Frau Biedermann und natürlich dem Lektoratsteam im Rheinwerk
Verlag. Herausgekommen ist ein Fachbuch über SQL, das
Einsteigern Schritt für Schritt erklärt, was es mit SQL auf sich hat.
Der »Einstieg in SQL« ist das Ergebnis einer hervorragenden
Teamarbeit und nicht das Werk eines einzelnen.
Ich wünsche Ihnen viel Spaß beim Lesen, Verstehen und
Ausprobieren. Und nochmal vielen Dank Christoph, Josha und
Sebastian!
Michael Laube
1 Grundlagen kennenlernen und
verstehen

Datenbanken und SQL haben in der Informatik die Aufgabe,


Daten auf eine einfache Art und Weise zu verwalten. Zentrale
Elemente sind die Abfragesprache SQL selbst, die Tabellen, in
denen die Daten gespeichert werden, und schließlich die
Datenbanksysteme, in denen die Tabellen und Daten hinterlegt
sind.

Sie haben eine gute Wahl getroffen, als Sie sich entschieden haben,
die Datenbankabfragesprache SQL zu lernen!
Datenbanken, die die Abfragesprache SQL unterstützen, sind
weltweit verbreitet. Sie werden in zahlreichen Unternehmen und
Institutionen verwendet, um Daten bzw. Informationen zu
strukturieren und effektiv zu verwalten. Denken Sie nur an
Versicherungen, Banken, Behörden und viele weitere Institutionen,
die darauf angewiesen sind, Informationen sicher und dauerhaft zu
verwalten.
Vermutlich interessiert Sie auch, wofür SQL überhaupt steht:
Structured Query Language.

Structured Query Language (SQL)

S → Structured (engl. für »strukturiert«)


Q → Query (engl. für »Abfrage«)
L → Language (engl. für »Sprache«)

SQL ist eine strukturierte Abfragesprache für Datenbanken.


Another random document with
no related content on Scribd:
"I hope you will forgive my apparent want of respect, mother. It was
not intentional, but this whole affair has been so sudden—brought
about, indeed, by such unforeseen circumstances—that I could
hardly help myself."

"If you had been a hot-headed lad of twenty, I could have understood
your conduct. At your age it is incomprehensible—inexcusable, I was
going to say. Put yourself in my place, if you can, and imagine what I
felt on hearing you say, 'This is my wife.' I, your mother, to whom you
had not deigned to send a word of warning."

"You had been so used to my coming home just when the humour
seized me—to my comet-like fashion of appearing and disappearing
—that I did not expect you would be so annoyed at my arriving
unannounced."

"Nor am I. It is to your wife's arrival—if this girl be indeed your wife."

Sir Philip started from his seat in anger. "This taunt is too much even
from you!" he exclaimed. "How dare you?"

"I dare anything. If the words sound harsh, you have brought them
on yourself by your rash act and forgetfulness of the respect you
owed me. What will the world say about Sir Philip Longridge's
marriage? Have you announced it in the papers, or is the world to
hear of it through gossiping servants?"

"I have made no announcement of my marriage to outsiders. You are


the first in England to hear of it. I crossed the Channel to-day, and
hurried to Northbrook with all possible speed. At least, mother, give
me credit for having lost no time in coming to you. If I had known
what I now do, I should have hesitated before bringing my wife
home!"

Sir Philip laid a bitter stress on the last word.

There was not much sign of feeling in the reply: "Now you are here
you had better tell me all about it."
But he complied with the half request conveyed in the words, and
told the story of his marriage as briefly as possible.

The father of Florence Winstanley, an enthusiastic traveller like


himself, had met with an accident during a mountain excursion. Sir
Philip found him at a village inn of the poorest description, and in an
out-of-the-world spot, just recovering his senses after many days
spent in delirious ravings or silent unconsciousness. He had watched
over him for weeks, and as soon as the sufferer was fit to be moved,
had travelled with him by easy stages to Geneva, where he had left
his daughter, and only child.

The homecoming was a terrible shock to the girl. Her father and she
were all in all to each other, and in addition to the trial of seeing him
so sadly changed, she soon had the greater one of knowing that he
had only returned to die at home. It was during the last month of Mr.
Winstanley's life that the man of mature years and the girl of
eighteen were drawn together; and Florence became engaged to
him who had first earned her gratitude by his devotion to her father.
They would not have married so soon, but for Mr. Winstanley's wish
to place his darling under the care of a loving husband before he
was called to leave the world. There was no doubt about the
affection of the two for each other, so they were married, and the
bride of a week stood by her father's grave, leaning on the arm of the
bridegroom, Sir Philip Longridge.

The pair lingered no longer than was necessary. There were


business matters to settle, and these completed, they turned their
faces homeward, to meet with the reception already described at
Northbrook Hall.

"You see, mother, I could hardly help myself," added Sir Philip. "We
were going to be married, but the fact of Mr. Winstanley's being on
his death-bed precipitated matters. There was no time to let you
know beforehand, and when the thing was done, why, it seemed so
much better to tell you all about it than to attempt to write. I know you
will feel a little annoyed, but after all you must see that the position
was peculiar, and my poor darling's sad loss and loneliness, to say
nothing of her lovely face and sweet nature, ought to appeal to your
motherly heart."

Lady Longridge's motherly heart! Who had ever heard an appeal to it


before? She turned coldly round and said, "The story is very
romantic, no doubt, but I should hardly have expected the loss, the
loneliness, or the fair face to turn the head of a man close upon forty.
I trust she has something more solid by way of recommendation. A
well-stocked purse, or a goodly dowry in houses and land, would
appeal with more power to my feelings than any of the qualifications
you have named."

"Florence has a little property, but she can draw only the income
from it, and that is about two hundred a year."

Lady Longridge fairly hissed out something in reply, but her son
could not distinguish the words. Her face was, however, almost
frightful in its anger, and there was silence for some minutes,
because she would not trust herself to speak, and Sir Philip deemed
it best to say nothing.

"How do you expect to keep up Northbrook?" she asked at last. "You


know your position, and that the paying out of your sisters' fortunes
left you but a narrow income, considering the calls upon you. As you
did not increase it by economy, or by devoting yourself to the
improvement of the estates, you were bound, if you did marry, to
choose a wife with money. I saved and pinched and scraped out of
my means. You spent all you had in your harum-scarum way, never
resting under your own roof, as a decent Christian should, but
wandering the world over, as if you had something on your
conscience, and squandering your money on those who doubtless
blessed you to your face and mocked you when your back was
turned. Then—"

"Then, mother, I borrowed from you and I owe you money now; but,
remember, you have had fair interest for it, regularly paid, and surely
it has been worth something to reign at Northbrook for eighteen
years, since I came of age."
"Only to lose my place now for that chit of a girl."

"Hush, mother! Say what you choose of me, but be silent or speak
kindly of my wife. I was going to say that I do not think Florence
would care to live at Northbrook, and my associations with my
birthplace are none of the sweetest. Circumstances may, however,
make it advisable for us to settle here. If so, there will be only room
for one mistress."

Sir Philip had touched the one tender spot at last. Lady Longridge
might have little room in her heart for her son, and none for his wife,
but she did long to live and die mistress of Northbrook Hall.

"You must pay me the four thousand pounds you owe me, before I
stir from this place," she said.

"That will be quite easy. You will remember that everything


connected with the loan was done as formally as though I were
borrowing from a stranger, and I am entitled to three months' notice,
but if you want the four thousand you can have it. I had a letter from
Mr. Melville quite lately, in which he asked if I knew of anyone who
wished to borrow a few thousands, for he is at his wits' end how to
invest some trust-money."

Foiled once more, Lady Longridge was puzzled what to say. She
decided to "sleep upon it," and, rising from her seat, remarked, "You
will be tired with your journey, and I am overdone with the shock I
have sustained. It would have been better to leave business matters
until to-morrow, so I will say good-night. You are master, and can
give your orders, you know."

She held out her hand—they were not demonstrative this mother
and son; he took it in his own for an instant, and having opened the
door for her, she passed out of the room and up the stairs without
another word.

When morning came, Lady Longridge had thought the matter out
and decided on her course of action. She would certainly come off
the worse in an open quarrel with her son. Her reign at the Hall
would be over. And she would either have to betake herself to a
smaller residence which was hers for life, or find a home elsewhere.
The house in question was well let and she had lived at the Hall rent
free hitherto. Thus she was touched in two tender spots—her liking
for Northbrook and her love of money.

For her own sake she resolved to conciliate that "chit of a girl whom
Philip had married." Thus she spoke of the new Lady Longridge to
Thorley.

But for once the elder lady found her match. The young wife, who
was pliable as wax in the hands of one she loved, had a will as
strong as that of her husband's mother, when roused by
circumstances to exert it.

The old lady might think she had only to hold out a finger and the
young one would run to seize it, but she found herself mistaken.
Florence was as little likely to bend by a hair's-breadth as was one of
the marble statues in the hall.

"My mother will be in a different humour this morning," said Sir Philip
to his wife, when the morning came. "I dare say she will make herself
very agreeable to you for the future."

"What she may do matters little to me, Philip. I am not likely to see
her. You will please order someone to bring my breakfast here—not
your mother's maid, who seems a kindly person, but of necessity a
sort of domestic spy."

"But surely, Florence, you will meet my mother again. After all, she
had cause to be aggrieved, and she is a lonely woman, getting on in
life."

"I should have thought that one who had known bereavement and
loneliness would have opened her heart to another in like
circumstances. Philip, I shall never forget your mother's look of
anger and hate as you spoke of your wife. It was directed at you, but
it seemed to turn me to stone. She is a fearful woman, Philip, and for
a world's wealth I would not live under the same roof with her."

Hitherto Sir Philip had only seen the tender, loving side of his wife's
character. He had noted her devotion to her suffering parent, her
utter forgetfulness of self, her unwearying patience. He had seen her
caring for the troubled, poverty-stricken people in her
neighbourhood, and finding time to give to others the help,
sympathy, and kind words of which she too stood so much in need.
He knew that she had given to himself no half-hearted affection, and
yet her love went hand in hand with the most exquisite modesty of
manner and speech. Now he saw the other side, and realized that
his wife's will would match that of his mother, and, between the two,
his position would be far from agreeable.

"Are you not rather hasty in coming to such a decision?" he asked.


"You have seen so little of my mother."

"Very little in one sense, too much in another. I would not have a
second experience like last night's for the world."

"Well, dearest, I will breakfast with my mother, and you shall have
your meal here. Afterwards we will talk matters over," was Sir Philip's
reply.

Lady Longridge had decided to meet both her son and his wife not
with two fingers, but with both arms extended. She found only her
son, who did not respond to her advances. After a formal greeting,
he relapsed into silence and the newspaper.

"How is Florence this morning? Rested, I hope, poor child! She


seemed almost hysterical last night, and no wonder. She was
wearied and overwrought."

"Thank you, she is better, but will breakfast in her room," replied Sir
Philip. "Do not trouble yourself, mother; I have already ordered
something to be sent up," for her hand was on the bell to summon a
servant.
"Thorley shall go to your wife immediately, Philip. She is a good
creature, as you know."

"It is very kind of you, but Florence will not deprive you of Thorley's
services, even for a short time. She prefers to be waited on by one of
the girls, thank you all the same."

And again Sir Philip devoted himself to the paper.

There was mischief brewing. Lady Longridge noted the stress on


those two words, and felt more uncomfortable than she would have
liked to confess. After an interval of silence she said—

"I know you like to linger over your last cup and the paper, so, if you
will excuse me, I will go up and see Florence."

She was not long absent. When she presented herself at the
bedroom door, she found it locked, and in answer to her knock and
request to be admitted, the voice of her daughter-in-law replied—

"I cannot see any one at present."

There was something in the tone which prevented Lady Longridge


from making a second application for admission, and she returned to
her son.

"Your wife will not admit me, Philip," she said.

"It is not always convenient to receive visitors when one is dressing,"


was the calm reply.

"She might have been civil."

"I have always found her more, and better, than merely civil, but she
may be adapting her manners to those prevailing at Northbrook."

And again he turned to the "Times."


Never before had Lady Longridge been puzzled what to do next.
After a short silence she said, in an ironical tone—

"Perhaps your wife will like to see Millward, and give her own orders,
since I must yield place to the new mistress of Northbrook."

"Perhaps so; though I doubt if Florence had realized the fact.


Millward may as well see her."

And, ignoring the irony in his mother's manner, Sir Philip rang for the
housekeeper, and told her she had better wait upon Lady Longridge
for orders.

The woman turned to her from whom she had been accustomed to
receive them; but Sir Philip said—

"I mean my wife. My mother herself suggested that this would be the
better plan. Your young mistress has not left her room yet, but she
may see you."

She did, for she was ready dressed, and after a while Millward
descended the stairs with two impressions on her mind. One was
that the new Lady Longridge had her wits about her, and, though she
was so young, would prove a match for the old one. The second that
there would be some pleasure in serving a beautiful creature like
that, who knew how to unite youth and beauty with dignity, and both
with a gracious manner that made it delightful to receive orders from
her.

A tyrannical mistress, who cares nothing for the feelings of her


subordinates, may nevertheless be well served by them. Self-interest
and fear may obtain this much, but such services will only be
rendered until a better opportunity presents itself. So, though
Millward had been twenty years at Northbrook, she went down-stairs
glad at heart with the thought that her "old lady" would meet her
match in Sir Philip's young wife.
CHAPTER III.
"MEN MAY COME AND MEN MAY GO,"

BUT I STAY ON FOR EVER.

WHEN Lady Longridge found that her daughter-in-law had promptly


accepted the position, and that Millward went straight to her own
domain instead of returning to her for the orders which she had felt
quite certain she would have to give as usual, she was extremely
angry. What added fuel to the fire was that she had brought about
this state of things by her own act. But she never dreamed that her
words would be taken in earnest. She only suggested that Florence
should give the orders, as a means of humiliating the young wife,
who could have had no experience of housekeeping in a place like
Northbrook Hall.

She appealed to Sir Philip, who merely reminded her that Millward
had gone to his with by her express wish.

"It was your doing, not mine," he said.

"I was not in earnest," she replied. "Was it likely that I should expect
that mere girl to take command here at a moment's notice?"

"Then it was a pity you said it, mother. I took it for granted that since
you made the suggestion it must be the right thing to do, though I am
sure Florence would have been in no hurry to assert herself. The
change must have come, of course, and perhaps it is as well that it
should be effected without any needless fuss, especially as you were
the first to propose it."
Yes, those incautious words, spoken ironically, but taken in earnest,
had done mischief which could never be repaired. She was deposed
without even a struggle, and yet had she not always resolved that
should Philip marry, she would show a brave fight before yielding the
chief place at Northbrook to a daughter-in-law?

It would take too long to tell how the two ladies were brought
together, outwardly as friends, but really as far asunder as the poles.
The young wife was the nominal head and mistress, but old Lady
Longridge remained at the Hall, in spite of all efforts to dislodge her.

She talked of going, but objected to more than one removal, and
said that she would reside at her own house when the present
tenant's lease was out; it would be only a matter of six months.
Surely Philip and Florence would not grudge her a shelter for so
long. It would be trial enough to leave a place which had been her
home for five-and-forty years, but a little delay would soften it to her.
So this was agreed to.

Lady Longridge knew how to utilise the advantage, and laughed


triumphantly to herself, as she set to work to regain lost ground.

"I made one mistake," she thought. "I will not repeat it. Philip's wife
has not got rid of the mother-in-law. I know him yet better than she
does. Phil is infatuated with her at present, but one gets accustomed
to the fairest face, and after a while the old roving temperament will
reassert itself. He has never stayed long in a place since he became
his own master, and he never will."

The astute old woman judged rightly. The restless fit came on again
before the end of three months. The young wife would not be left
behind; the time for the mother's removal had not arrived, so the pair
departed on their travels and left Lady Longridge, senior, at the Hall,
but with the understanding that she would vacate it as arranged.

"When we return we shall have our house to ourselves," said Sir


Philip to his wife. He felt that whilst she and his mother preserved an
appearance of friendliness, and the elder lady carefully abstained
from interfering in household matters, there was no real goodwill
between them.

"I doubt it, Philip. Your mother will not move from Northbrook if she
can help it."

"But she agreed to go at the six months' end, and considered it a


favour to be allowed to stay so long."

"You will see when the time is up. I only hope you may be right."

It was a month past the six when the pair came back, and they found
Lady Longridge, senior, still at the Hall. "Too ill to be moved," she
said.

At any rate she had kept her room for several weeks, and still
professed her inability to leave it.

"Have the Wilmotts left Graylands?" asked her son.

"No, Philip. They are staying on as yearly tenants. I shall not have a
house to myself when I leave here. My health is quite broken. The
thought of turning my back on Northbrook has been quite too much
for me, and I shall not again trouble myself with housekeeping cares.
Rooms will suffice for me and Thorley, and be much better suited to
my income. I can move about, ringing the changes on Brighton, St.
Leonards, or Scarborough in summer, and Torquay or Bournemouth
in winter. It will matter little to me; only I shall see fresh faces, and be
the same lonely old woman everywhere, away from Northbrook. You
will take me in for a week or two now and then, if Florence is
agreeable? Or I can stay at one of the farms."

Sir Philip said something about his mother finding it pleasant to visit
her daughters also.

"Never," she replied. "They went their way, and I shall go mine. How
much have I seen of them in more than twenty years? I have only my
son." And Lady Longridge wiped her eyes, but the light was dim, and
tears were strange to them, so perhaps there was no real moisture
there. At any rate, Sir Philip could discern none.

Many a date was fixed for the old lady's departure, but something
always prevented it.

Sixteen years had come and gone between the homecoming of Sir
Philip Longridge with his bride and the fair spring morning when
Thorley was sent to silence the too-tuneful Margaretta. But during
the whole time Lady Longridge had not spent a night under any roof
but that of Northbrook Hall. And now she reigned supreme there, for
her son was dead, his widow married a second time, and Margaretta
lived with her grandmother. There was no grandson, so the baronet
of to-day was a far-away cousin, who had a finer place elsewhere,
and Lady Longridge occupied her old home, for which she paid a
rent which was little more than nominal, but which she made a cause
for infinite grumbling.

Of personal property Sir Philip had not much to leave. The two
hundred a year belonging to his wife was not doubled by what he
could bequeath, but what there was became hers absolutely. He
never believed she would marry again, but in case of her so doing,
he willed that his mother was to have the guardianship of
Margaretta, and he trusted to her to make a suitable provision for his
child, knowing that she was well able to do so.

Margaretta was twelve years old when her father died, and
Northbrook was no longer even a temporary refuge for the widow
and her child.

Sir Philip had never cared to stay long at the Hall, and where he
went his wife accompanied him, but the child was usually there
under suitable guardianship, her nurse first, then a capable
governess being answerable to her parents for their charge's well-
doing.

Old Lady Longridge and her daughter-in-law had not become better
friends, and the former was altogether more impracticable at
seventy-eight than she had been at sixty-five. One roof could not
shelter the two, and the young widow was as eager to leave
Northbrook as the older was to get rid of her.

Florence Longridge was a proud woman, and it was a trial for her to
give up the surroundings she had been used to as Sir Philip's wife,
and to live on a narrow income, with a daughter to educate in a
manner befitting her birth. She would have died sooner than ask help
from her mother-in-law, even had she expected to receive it for the
asking. At thirty-four she was almost more beautiful than in her
girlish days, and no less attractive for her intellectual gifts.

After two years' widowhood she accidentally met an old friend of her
husband, one for whom Sir Philip ever expressed the greatest
esteem. He was a man of forty, with wealth, position, and an
honoured name. When he asked her to be his wife she hesitated,
only on her child's account.

"If I marry, I must part with Margaretta," she said. "I am her guardian
only whilst I am a widow."

"Only for a few years, and though she may go to her grandmother, I
will help you still to guard and care for her until she is of age, though,
considering all things, she may return to you before then."

The marriage took place; Lady Longridge claimed her ward, and
having got possession of Margaretta, succeeded in keeping her out
of her mother's presence, except for a short time at the end of every
six months, when she was obliged to permit a meeting by the terms
of her son's will. Probably if Sir Philip could have foreseen events, he
would have rather rejoiced to leave his child in such worthy hands as
those of his friend Hugh Norland, in his position of stepfather to
Margaretta. But the thought of his wife's second marriage was one
he could not endure, so he had ordered matters otherwise, and the
girl was with her grim old kinswoman.

"Thorley," said Lady Longridge, after Margaretta's arrival, "we have


caged our bird once more, and we shall keep her safely, never fear.
The thought of having the charge of her for—let me see—six years
to come, will help to keep me alive. I dare say her mother will count
my years and say, 'She will not last till Margaretta is of age.' But
plenty of people live to eighty-seven, and why not I. I come of a long-
lived race; at least the females live long. I am only angry at one
thing. Mrs. Hugh Norland has far too much money now. I hate to
think of her being rich—far richer than she ever was as Philip's wife.
And she will not give a penny towards Margaretta's maintenance,
shame on her!"

It was true that Mrs. Norland declined to relieve Lady Longridge's


purse, unless she were permitted to have a say in her daughter's
education and in spending the money. This granted, she would have
given any reasonable amount. But much as the old lady loved to
save, she liked still better to punish the daughter-in-law who had
once made her fill a secondary position, and she availed herself to
the utmost of her powers as the legally appointed guardian of
Margaretta.

The girl had a sorry time at Northbrook. She had no companions of


her own age, and indeed, visitors of any age were few and far
between at the Hall. The rector, a new one in Dr. Darley's place,
came, as in duty bound, and always felt, as the door closed behind
him, that the most disagreeable of his pastoral calls was over for the
time being.

Now and then a carriage would pass along the neglected drive, and
ladies would alight from it and spend a short time with Lady
Longridge, who, however, never returned such visits.

"I am too old for gadding about, so each call you are good enough to
pay will only add to my debts," she would say. "However, it is some
comfort to know that nobody cares to see an old lady like me. It is
not likely. I hear nothing, so I have nothing to tell, and I miss one-half
of what people say through not hearing. Then I repeat the tale
wrongly to the next comer, and get into trouble; so you see it would
have been better not to hear or speak."
An inquiry after Margaretta usually made the old lady eloquent.

"My granddaughter! I never know where she is, except at meal-


times, for she is here, there, and everywhere between-whiles. I hear
her often enough—too often, for she is always making a noise which
she calls singing. It is a dreadful trial for an old woman like me to be
burdened with the charge of a girl. But Philip would not leave her to
the tender mercies of a stepfather, and that devoted wife of his would
not keep single for the sake of her 'darling child.' Oh no."

It was always the same. No kind word fur any one, no messenger
sent to bring the lonely girl into the presence of a visitor who might
have been inclined to make her life a little brighter.

Yet Margaretta was not wholly friendless. She had, after a time, three
persons on whose affection she could rely, and all within her reach at
Northbrook.

First of these was Thorley, who had known her from her birth, and
who, in spite of all her mistress could do to the contrary, had never
missed an opportunity of showing her devoted love for the girl. When
Margaretta was a baby, Thorley used to steal away to the nursery
and satisfy the hunger of a loving woman's heart by spending her
few spare moments with the child. She was full of devices for her
amusement, having been herself "the eldest of nine and used to
nursing," and was in consequence the little one's first favourite.

So when Margaretta came back to Northbrook after the interval


between her father's death and her mother's second marriage,
Thorley's was the only familiar face she saw there beside her
grandmother's.

Lady Longridge's first act on finding herself sole mistress of the Hall
had been to make "a clean sweep" of all the servants, Thorley
excepted.

"Not one who ever received orders from Florence shall stay in my
service," she said, and carried out her resolution.
This change rendered it easy for her to reduce her establishment.
"Half the servants ought to be enough to wait on one old woman,"
she said next, and then she decided to spare her purse further by
giving less wages for less trained domestics. No wonder that, inside
and out, the appearance of Northbrook had changed for the worse
since its old mistress resumed her absolute rule there.

"Things will last my time. Let those who follow renew. There are
gewgaws enough that Florence put in and that are not worth house-
room, only that as my landlord took them at a valuation, and I have
nothing to fill their places if they were removed, they may as well
stay where they are."

The gewgaws were all the dainty screens, needlework, elegant


lamp-shades and artistic trifles with which Sir. Philip's wife had
beautified the barrenness of the rooms. All the more substantial
articles were old-fashioned, the last possessor having had no spare
money to spend on refurnishing the Hall.

Margaretta's second and only young friend was a little village


seamstress named Ellen Corry, by whose deft fingers the garments
of the growing girl were remodelled let out and lengthened, as
occasion required.

It was fortunate for Margaretta that she brought with her a good
stock of clothes, and that the materials were admirably chosen both
as to colours and quality—soft, beautiful, girlish, and not likely to
become conspicuous, owing to the changes of fashion. Each
garment had been carefully planned so as to permit of enlargement,
and a length of new material was folded with it for future renovation.

Lady Longridge grunted indignantly as she caused Thorley to pass


Margaretta's wardrobe in review before her. It was in one sense
satisfactory to find that no expenditure of money would be needed
for a long time.

"I should have bought nothing new in any case," snapped out the old
lady. "There are coloured gowns enough of mine laid away that
would have done for the girl, and they will come in when these are
worn out. Take all this frippery away," and she waved off Thorley and
the garments with an impatient gesture.

The maid retired, murmuring a thanksgiving that her darling Miss


Margaretta would be preserved from the ancient horrors laid up by
her mistress, professedly for future wear, but never likely to be
needed.

"A lady's maid," muttered Thorley, "is supposed to get good pickings
out of her mistress's clothes, but I never had any that were worth
selling, much less wearing. However, it is some comfort to think that,
while she goes on hoarding her rubbish, I never feel to covet any of
and one may be thankful not to be tempted. As to Miss Margaretta,
Nelly Corry will keep her right for a couple of years, let her grow as
fast as she likes."

Nelly Corry's aid was soon needed, and in her joy at the sight of a
young face, Margaretta, albeit an unskilful seamstress, determined
to help her in her work.

"I can unpick the seams, if I cannot put them together," she said, and
this she did with her grandmother's approval, qualified, however, by
the remark that it would be a change to see her occupied in anything
but mischief. Nelly was a good, pure-minded little creature, the staff
of her widowed mother, and the child of careful training and many
prayers. No fear that from her Margaretta would receive harm, or
that the dingy nursery, now used as a workroom, would be the scene
of gossip or idle tattle. The baronet's child and the seamstress a few
years older were just a couple of innocent-minded girls, very happy
only to be together, because they were young, and each had no
friend of like age under the roof she called home.

Nelly's home was a real one, and the girl was eloquent always about
her mother's goodness and the wealth of loving care she bestowed
on the only child left her there. The rest were married and gone out
into the world. Only the one ewe lamb was left.
How different with Margaretta! She could only say that she wished
she could ever please her grandmother, who did not, and she
thought never would, love her. That she longed for the mother from
whom she was parted, and was sure that if only she could be with
her and Mr. Norland, he would love her too. For she had known him
when she was a little thing, and he was—oh, so nice always!

"I want the days to go twice as fast, and they pass so slowly here. I
used to think lessons a nuisance, and wish I had only half as many.
Now I should be glad to be properly taught again. My old governess
would not live with grandmother if she might, and grandmother would
not have her or pay her. She thinks anything spent on me is thrown
away, and says I know more than I ought already. She hates music.
Mamma's piano is gone, and the old one here is horrible, no two
notes in tune. It must be a hundred years old, I should think. And
grandmother is glad it is so bad, for she says if it were a good
instrument, I should be at it always, as mamma used to be at hers,
and there would be no peace. It is just the same if I sing. I went out
of doors to-day, and thought she could not hear me, but she did, and
sent Thorley to say I was to stop that screaming, for it was worse
than a railway-whistle."

"Did Miss Thorley say that?" asked Nelly, who had a profound
veneration for Lady Longridge's maid, and thought it impossible for
her to say a harsh word.

"No. She came to me with such a heartbroken look, for she loves to
hear me sing, and says my voice is the only pleasant thing she
hears. I had just put myself in a comfortable place, leaning against a
tree, and she stole up to me looking miserable when I was in the
midst of a fresh song. 'Don't tell me the message,' I said, 'I will tell
you. Grandmother has sent you to bid me stop screeching. I am
right, am I not?'"

"'Yes, my darling. That is just what my lady did say. It seems as if


you cannot get out of hearing, so as to sing in peace, and yet she is
always complaining of being deaf, and turning what people say into
nonsense. She hears well enough. She only pretends to
misunderstand them, so that she may catch things that were never
meant for her ears at all.'"

"Then I wished I were a bird, and that I could fly out of hearing. I
sometimes think I shall run away, Nelly, for life here is so dreadful.
And to have to live it for six long years, or five and a half, for I have
been here a few months already! Thorley was quite shocked, and
said, 'Oh, dear Miss Margaretta, you make me tremble, and I am just
as nervous as I can be to begin with, through your grandma
scolding.'"

"'If you don't call me "Meg," I will start off this minute,' I said. 'I can
run so fast that I should be out of reach before you could begin to
follow.'"

"Then Thorley gasped out, 'Oh, Meg, do not,' and I laughed until I
forgot my grandmother's cross message. You see I make Thorley
call me 'Meg,' because it was my poor father's pet name for me, and
mamma got into the way of using it too. No one but those who loved
me ever used it, so I ask Thorley to say it, because I want to feel
loved yet, and she does care for me."

"She does indeed. And, dear Miss Longridge, so do I. There isn't a


thing you could ask me to do that I would not do for you."

"Then call me 'Meg' this minute, you dear little nice thing," said
Margaretta, and then she flung her arm round the little seamstress's
neck and kissed her with such energy that Nelly was half frightened
at the suddenness of the embrace.

"Kiss me back again. Kiss me, Nelly," cried Margaretta. "Don't you
see I am hungering for love and kindness? Thorley is an old dear,
but I want a young one. I will have you for a friend. I like you, and
grandmother gives me no choice."

So on that day a compact was entered into, and Nelly returned


Margaretta's somewhat tempestuous affection with an almost
worshipping devotion, calling her "Meg" in a whisper, as Thorley did
when no one was within hearing, and resolving that if ever she in her
humble way could help the lonely young lady, she would do it with all
her might.

One thing she succeeded in making Margaretta promise when, from


time to time, she threatened to run away, and that was that she
would go straight to Nelly's home, and no further, to begin with.

To this Margaretta agreed, and both Nelly and Thorley, whom she
informed of the arrangement, were content.

It was through the little seamstress that Meg gained her third friend,
and the one who was likely to be of the most service to her.

CHAPTER IV.
THE MOUSE HELPS THE LIONESS,

AND MARGARETTA GAINS A THIRD FRIEND.

NELLY CORRY'S active fingers were never idle, and her cleverness,
good taste, and modest manners were the means of introducing her
to the best houses in the neighbourhood, as well as to Northbrook
Hall. One of her customers, a childless widow, resided in a pretty
cottage about half a mile from it.

This lady, Mrs. Moffat, was much interested in the little seamstress,
who was so good a daughter and so industrious, and very often
made the girl bring her work into her own sitting-room. There the

Das könnte Ihnen auch gefallen