100% found this document useful (2 votes)
418 views55 pages

[Ebooks PDF] download Learning SQL Master SQL Fundamentals Alan Beaulieu full chapters

Beaulieu

Uploaded by

ngajiaiilen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
418 views55 pages

[Ebooks PDF] download Learning SQL Master SQL Fundamentals Alan Beaulieu full chapters

Beaulieu

Uploaded by

ngajiaiilen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Experience Seamless Full Ebook Downloads for Every Genre at textbookfull.

com

Learning SQL Master SQL Fundamentals Alan Beaulieu

https://textbookfull.com/product/learning-sql-master-sql-
fundamentals-alan-beaulieu/

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

T SQL Fundamentals Itzik Ben-Gan

https://textbookfull.com/product/t-sql-fundamentals-itzik-ben-gan/

textboxfull.com

SQL Easy SQL Programming Database Management for Beginners


Your Step By Step Guide to Learning the SQL Database Felix
Alvaro
https://textbookfull.com/product/sql-easy-sql-programming-database-
management-for-beginners-your-step-by-step-guide-to-learning-the-sql-
database-felix-alvaro/
textboxfull.com

SQL Primer: An Accelerated Introduction to SQL Basics


Rahul Batra

https://textbookfull.com/product/sql-primer-an-accelerated-
introduction-to-sql-basics-rahul-batra/

textboxfull.com

SQL Server Execution Plans For SQL Server 2008 through to


2017 and Azure SQL Database 3rd Edition Grant Fritchey

https://textbookfull.com/product/sql-server-execution-plans-for-sql-
server-2008-through-to-2017-and-azure-sql-database-3rd-edition-grant-
fritchey/
textboxfull.com
Practical guide to Oracle SQL, T-SQL and MySQL 1st Edition
Preston Zhang

https://textbookfull.com/product/practical-guide-to-oracle-sql-t-sql-
and-mysql-1st-edition-preston-zhang/

textboxfull.com

Azure SQL Revealed: A Guide to the Cloud for SQL Server


Professionals Bob Ward

https://textbookfull.com/product/azure-sql-revealed-a-guide-to-the-
cloud-for-sql-server-professionals-bob-ward/

textboxfull.com

SQL Cookbook: Query Solutions and Techniques for All SQL


Users 2nd Edition Anthony Molinaro

https://textbookfull.com/product/sql-cookbook-query-solutions-and-
techniques-for-all-sql-users-2nd-edition-anthony-molinaro/

textboxfull.com

SQL Server 2019 Revealed: Including Big Data Clusters and


Machine Learning Bob Ward

https://textbookfull.com/product/sql-server-2019-revealed-including-
big-data-clusters-and-machine-learning-bob-ward/

textboxfull.com

Expert SQL Server Transactions and Locking: Concurrency


Internals for SQL Server Practitioners 1st Edition Dmitri
Korotkevitch
https://textbookfull.com/product/expert-sql-server-transactions-and-
locking-concurrency-internals-for-sql-server-practitioners-1st-
edition-dmitri-korotkevitch/
textboxfull.com
1. Preface
a. Why Learn SQL?
b. Why Use This Book to Do It?
c. Structure of This Book
d. Conventions Used in This Book
e. Using Code Examples
f. O’Reilly Online Learning
g. How to Contact Us
2. 1. A Little Background
a. Introduction to Databases

i. Nonrelational Database Systems


ii. The Relational Model
iii. Some Terminology
b. What Is SQL?

i. SQL Statement Classes


ii. SQL: A Nonprocedural Language
iii. SQL Examples

c. What Is MySQL?
d. SQL Unplugged
e. What’s in Store

3. 2. Creating and Populating a Database


a. Creating a MySQL Database
b. Using the mysql Command-Line Tool
c. MySQL Data Types
i. Character Data
ii. Numeric Data
iii. Temporal Data
d. Table Creation

i. Step 1: Design
ii. Step 2: Refinement
iii. Step 3: Building SQL Schema
Statements
e. Populating and Modifying Tables

i. Inserting Data
ii. Updating Data
iii. Deleting Data
f. When Good Statements Go Bad

i. Nonunique Primary Key


ii. Nonexistent Foreign Key
iii. Column Value Violations
iv. Invalid Date Conversions

g. The Sakila Database


4. 3. Query Primer
a. Query Mechanics
b. Query Clauses
c. The select Clause

i. Column Aliases
ii. Removing Duplicates

d. The from Clause

i. Tables
ii. Table Links
iii. Defining Table Aliases

e. The where Clause


f. The group by and having Clauses
g. The order by Clause

i. Ascending Versus Descending Sort


Order
ii. Sorting via Numeric Placeholders

h. Test Your Knowledge


i. Exercise 3-1
ii. Exercise 3-2
iii. Exercise 3-3
iv. Exercise 3-4
5. 4. Filtering
a. Condition Evaluation
i. Using Parentheses
ii. Using the not Operator
b. Building a Condition
c. Condition Types

i. Equality Conditions
ii. Range Conditions
iii. Membership Conditions
iv. Matching Conditions
d. Null: That Four-Letter Word
e. Test Your Knowledge

i. Exercise 4-1
ii. Exercise 4-2
iii. Exercise 4-3
iv. Exercise 4-4
6. 5. Querying Multiple Tables

a. What Is a Join?
i. Cartesian Product
ii. Inner Joins
iii. The ANSI Join Syntax

b. Joining Three or More Tables


i. Using Subqueries As Tables
ii. Using the Same Table Twice
c. Self-Joins
d. Test Your Knowledge
i. Exercise 5-1
ii. Exercise 5-2
iii. Exercise 5-3
7. 6. Working with Sets

a. Set Theory Primer


b. Set Theory in Practice
c. Set Operators

i. The union Operator


ii. The intersect Operator
iii. The except Operator
d. Set Operation Rules

i. Sorting Compound Query Results


ii. Set Operation Precedence
e. Test Your Knowledge

i. Exercise 6-1
ii. Exercise 6-2
iii. Exercise 6-3
8. 7. Data Generation, Manipulation, and Conversion

a. Working with String Data


i. String Generation
ii. String Manipulation
b. Working with Numeric Data
i. Performing Arithmetic Functions
ii. Controlling Number Precision
iii. Handling Signed Data

c. Working with Temporal Data


i. Dealing with Time Zones
ii. Generating Temporal Data
iii. Manipulating Temporal Data

d. Conversion Functions
e. Test Your Knowledge
i. Exercise 7-1
ii. Exercise 7-2
iii. Exercise 7-3
9. 8. Grouping and Aggregates
a. Grouping Concepts
b. Aggregate Functions

i. Implicit Versus Explicit Groups


ii. Counting Distinct Values
iii. Using Expressions
iv. How Nulls Are Handled

c. Generating Groups
i. Single-Column Grouping
ii. Multicolumn Grouping
iii. Grouping via Expressions
iv. Generating Rollups
d. Group Filter Conditions
e. Test Your Knowledge

i. Exercise 8-1
ii. Exercise 8-2
iii. Exercise 8-3
10. 9. Subqueries

a. What Is a Subquery?
b. Subquery Types
c. Noncorrelated Subqueries

i. Multiple-Row, Single-Column
Subqueries
ii. Multicolumn Subqueries

d. Correlated Subqueries

i. The exists Operator


ii. Data Manipulation Using Correlated
Subqueries

e. When to Use Subqueries


i. Subqueries As Data Sources
ii. Subqueries As Expression Generators
f. Subquery Wrap-up
g. Test Your Knowledge

i. Exercise 9-1
ii. Exercise 9-2
iii. Exercise 9-3
11. 10. Joins Revisited

a. Outer Joins

i. Left Versus Right Outer Joins


ii. Three-Way Outer Joins
b. Cross Joins
c. Natural Joins
d. Test Your Knowledge
i. Exercise 10-1
ii. Exercise 10-2
iii. Exercise 10-3 (Extra Credit)
12. 11. Conditional Logic

a. What Is Conditional Logic?


b. The Case Expression

i. Searched Case Expressions


ii. Simple Case Expressions
c. Case Expression Examples

i. Result Set Transformations


ii. Checking for Existence
iii. Division-by-Zero Errors
iv. Conditional Updates
v. Handling Null Values
d. Test Your Knowledge

i. Exercise 11-1
ii. Exercise 11-2
13. 12. Transactions

a. Multiuser Databases
i. Locking
ii. Lock Granularities

b. What Is a Transaction?

i. Starting a Transaction
ii. Ending a Transaction
iii. Transaction Savepoints

c. Test Your Knowledge


i. Exercise 12-1

14. 13. Indexes and Constraints

a. Indexes

i. Index Creation
ii. Types of Indexes
iii. How Indexes Are Used
iv. The Downside of Indexes
b. Constraints

i. Constraint Creation

c. Test Your Knowledge

i. Exercise 13-1
ii. Exercise 13-2
15. 14. Views
a. What Are Views?
b. Why Use Views?

i. Data Security
ii. Data Aggregation
iii. Hiding Complexity
iv. Joining Partitioned Data

c. Updatable Views

i. Updating Simple Views


ii. Updating Complex Views

d. Test Your Knowledge


i. Exercise 14-1
ii. Exercise 14-2

16. 15. Metadata

a. Data About Data


b. Information_Schema
c. Working with Metadata

i. Schema Generation Scripts


ii. Deployment Verification
iii. Dynamic SQL Generation
d. Test Your Knowledge

i. Exercise 15-1
ii. Exercise 15-2
17. 16. Analytic Functions

a. Analytic Function Concepts

i. Data Windows
ii. Localized Sorting

b. Ranking
i. Ranking Functions
ii. Generating Multiple Rankings

c. Reporting Functions

i. Window Frames
ii. Lag and Lead

d. Test Your Knowledge


i. Exercise 16-1
ii. Exercise 16-2
iii. Exercise 16-3

18. 17. Working with Large Databases


a. Partitioning

i. Partitioning Concepts
ii. Table Partitioning
iii. Index Partitioning
iv. Partitioning Methods
v. Partitioning Benefits

b. Sharding
c. Big Data

i. Hadoop
ii. NoSQL and Document Databases
iii. Cloud Computing
iv. Future of SQL
19. 18. SQL and Big Data

a. Apache Drill
b. Drill and MySQL
c. Drill and MongoDB
d. Drill with Multiple Data Sources
Learning SQL
THIRD EDITION

Generate, Manipulate, and Retrieve Data

With Early Release ebooks, you get books in their earliest form—the author’s
raw and unedited content as they write—so you can take advantage of these
technologies long before the official release of these titles.

Alan Beaulieu
Learning SQL

by Alan Beaulieu

Copyright © 2020 Alan Beaulieu. All rights reserved.

Printed in the United States of America.

Published by O’Reilly Media, Inc., 1005 Gravenstein Highway


North, Sebastopol, CA 95472.

O’Reilly books may be purchased for educational, business, or


sales promotional use. Online editions are also available for
most titles (http://oreilly.com/safari). For more information,
contact our corporate/institutional sales department: 800-998-
9938 or [email protected].

Acquisitions Editor: Jessica Haberman

Development Editor: Jeff Bleiel

Production Editor: Deborah Baker

Interior Designer: David Futato

Cover Designer: Karen Montgomery

Illustrator: Rebecca Demarest

May 2020: Third Edition


Revision History for the Early Release
2019-12-11: First Release

See http://oreilly.com/catalog/errata.csp?isbn=9781492057611
for release details.

The O’Reilly logo is a registered trademark of O’Reilly Media,


Inc. Learning SQL, the cover image, and related trade dress
are trademarks of O’Reilly Media, Inc.

The views expressed in this work are those of the author, and
do not represent the publisher’s views. While the publisher and
the author have used good faith efforts to ensure that the
information and instructions contained in this work are
accurate, the publisher and the author disclaim all
responsibility for errors or omissions, including without
limitation responsibility for damages resulting from the use of
or reliance on this work. Use of the information and
instructions contained in this work is at your own risk. If any
code samples or other technology this work contains or
describes is subject to open source licenses or the intellectual
property rights of others, it is your responsibility to ensure that
your use thereof complies with such licenses and/or rights.

978-1-492-05754-3

[LSI]
Preface
Programming languages come and go constantly, and very few
languages in use today have roots going back more than a
decade or so. Some examples are Cobol, which is still used
quite heavily in mainframe environments, and C, which is still
quite popular for operating system and server development
and for embedded systems. In the database arena, we have
SQL, whose roots go all the way back to the 1970s.

SQL is the language for generating, manipulating, and


retrieving data from a relational database. One of the reasons
for the popularity of relational databases is that properly
designed relational databases can handle huge amounts of
data. When working with large data sets, SQL is akin to one of
those snazzy digital cameras with the high-power zoom lens in
that you can use SQL to look at large sets of data, or you can
zoom in on individual rows (or anywhere in between). Other
database management systems tend to break down under
heavy loads because their focus is too narrow (the zoom lens is
stuck on maximum), which is why attempts to dethrone
relational databases and SQL have largely failed. Therefore,
even though SQL is an old language, it is going to be around
for a lot longer and has a bright future in store.
Why Learn SQL?
If you are going to work with a relational database, whether
you are writing applications, performing administrative tasks,
or generating reports, you will need to know how to interact
with the data in your database. Even if you are using a tool
that generates SQL for you, such as a reporting tool, there may
be times when you need to bypass the automatic generation
feature and write your own SQL statements.

Learning SQL has the added benefit of forcing you to confront


and understand the data structures used to store information
about your organization. As you become comfortable with the
tables in your database, you may find yourself proposing
modifications or additions to your database schema.
Why Use This Book to Do It?
The SQL language is broken into several categories.
Statements used to create database objects (tables, indexes,
constraints, etc.) are collectively known as SQL schema
statements. The statements used to create, manipulate, and
retrieve the data stored in a database are known as the SQL
data statements. If you are an administrator, you will be using
both SQL schema and SQL data statements. If you are a
programmer or report writer, you may only need to use (or be
allowed to use) SQL data statements. While this book
demonstrates many of the SQL schema statements, the main
focus of this book is on programming features.

With only a handful of commands, the SQL data statements


look deceptively simple. In my opinion, many of the available
SQL books help to foster this notion by only skimming the
surface of what is possible with the language. However, if you
are going to work with SQL, it behooves you to understand
fully the capabilities of the language and how different features
can be combined to produce powerful results. I feel that this is
the only book that provides detailed coverage of the SQL
language without the added benefit of doubling as a “door
stop” (you know, those 1,250-page “complete references” that
tend to gather dust on people’s cubicle shelves).

While the examples in this book run on MySQL, Oracle


Database, and SQL Server, I had to pick one of those products
to host my sample database and to format the result sets
returned by the example queries. Of the three, I chose MySQL
because it is freely obtainable, easy to install, and simple to
administer. For those readers using a different server, I ask
that you download and install MySQL and load the sample
database so that you can run the examples and experiment
with the data.

Structure of This Book


This book is divided into 15 chapters and 3 appendixes:

Chapter 1, explores the history of computerized


databases, including the rise of the relational model
and the SQL language.

Chapter 2, demonstrates how to create a MySQL


database, create the tables used for the examples in
this book, and populate the tables with data.

Chapter 3, introduces the selectstatement and


further demonstrates the most common clauses
(select, from, where).
Chapter 4, demonstrates the different types of
conditions that can be used in the whereclause of a
select, update, or deletestatement.

Chapter 5, shows how queries can utilize multiple tables


via table joins.

Chapter 6, is all about data sets and how they can


interact within queries.

Chapter 7, demonstrates several built-in functions used


for manipulating or converting data.

Chapter 8, shows how data can be aggregated.

Chapter 9, introduces the subquery (a personal


favorite) and shows how and where they can be
utilized.
Chapter 10, further explores the various types of table
joins.

Chapter 11, explores how conditional logic (i.e., if-then-


else) can be utilized in select, insert, update, and
deletestatements.

Chapter 12, introduces transactions and shows how to


use them.

Chapter 13, explores indexes and constraints.

Chapter 14, shows how to build an interface to shield


users from data complexities.

Chapter 15, demonstrates the utility of the data


dictionary.

Appendix A shows the database schema used for all


examples in the book.

Appendix B demonstrates some of the interesting non-


ANSI features of MySQL’s SQL implementation.

Appendix C shows solutions to the chapter exercises.

Conventions Used in This Book


The following typographical conventions are used in this book:

Italic

Used for filenames, directory names, and URLs. Also used


for emphasis and to indicate the first use of a technical
term.

Constant width

Used for code examples and to indicate SQL keywords


within text.

Constant width italic

Used to indicate user-defined terms.

plainUPPERCASE
Used to indicate SQL keywords within example code.

Constant width bold

Indicates user input in examples showing an interaction.


Also indicates emphasized code elements to which you
should pay particular attention.

NOTE
Indicates a tip, suggestion, or general note. For example, I use notes to
point you to useful new features in Oracle9i.

WARNING
Indicates a warning or caution. For example, I’ll tell you if a certain SQL
clause might have unintended consequences if not used carefully.

Using Code Examples


This book is here to help you get your job done. In general, if
example code is offered with this book, you may use it in your
programs and documentation. You do not need to contact us
for permission unless you’re reproducing a significant portion
of the code. For example, writing a program that uses several
chunks of code from this book does not require permission.
Selling or distributing examples from O’Reilly books does
require permission. Answering a question by citing this book
and quoting example code does not require permission.
Incorporating a significant amount of example code from this
book into your product’s documentation does require
permission.

We appreciate, but generally do not require, attribution. An


attribution usually includes the title, author, publisher, and
ISBN. For example: “Learning SQL, Third Edition, by Alan
Beaulieu. Copyright 2020 Alan Beaulieu, 978-1-492-05761-1.”

If you feel your use of code examples falls outside fair use or
the permission given above, feel free to contact us at
[email protected].

O’Reilly Online Learning

NOTE
For more than 40 years, O’Reilly has provided technology and business
training, knowledge, and insight to help companies succeed.

Our unique network of experts and innovators share their


knowledge and expertise through books, articles, conferences,
and our online learning platform. O’Reilly’s online learning
platform gives you on-demand access to live training courses,
in-depth learning paths, interactive coding environments, and a
vast collection of text and video from O’Reilly and 200+ other
publishers. For more information, please visit
http://oreilly.com.

How to Contact Us
Please address comments and questions concerning this book
to the publisher:

O’Reilly Media, Inc.

1005 Gravenstein Highway North

Sebastopol, CA 95472

800-998-9938 (in the United States or Canada)

707-829-0515 (international or local)

707-829-0104 (fax)

We have a web page for this book, where we list errata,


examples, and any additional information. You can access this
page at http://www.oreilly.com/catalog/9781492057611.

Emails us with comments or technical questions at


[email protected].

For more information about our books, courses, conferences,


and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly


Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia


Chapter 1. A Little
Background
Before we roll up our sleeves and get to work, it would be
helpful to survey the history of database technology in order to
better understand how relational databases and the SQL
language evolved. Therefore, I’d like to start by introducing
some basic database concepts and looking at the history of
computerized data storage and retrieval.

NOTE
For those readers anxious to start writing queries, feel free to skip ahead
to Chapter 3, but I recommend returning later to the first two chapters in
order to better understand the history and utility of the SQL language.

Introduction to Databases
A database is nothing more than a set of related information. A
telephone book, for example, is a database of the names,
phone numbers, and addresses of all people living in a
particular region. While a telephone book is certainly a
ubiquitous and frequently used database, it suffers from the
following:
Finding a person’s telephone number can be time-
consuming, especially if the telephone book contains a
large number of entries.

A telephone book is indexed only by last/first names,


so finding the names of the people living at a particular
address, while possible in theory, is not a practical use
for this database.

From the moment the telephone book is printed, the


information becomes less and less accurate as people
move into or out of a region, change their telephone
numbers, or move to another location within the same
region.

The same drawbacks attributed to telephone books can also


apply to any manual data storage system, such as patient
records stored in a filing cabinet. Because of the cumbersome
nature of paper databases, some of the first computer
applications developed were database systems, which are
computerized data storage and retrieval mechanisms. Because
a database system stores data electronically rather than on
paper, a database system is able to retrieve data more quickly,
index data in multiple ways, and deliver up-to-the-minute
information to its user community.

Early database systems managed data stored on magnetic


tapes. Because there were generally far more tapes than tape
readers, technicians were tasked with loading and unloading
Discovering Diverse Content Through
Random Scribd Documents
She was coming in from the fishing grounds bound to Boston
with 20,000 pounds of cod and haddock. The Coast Guardsmen
from Cahoon’s Hollow Station were promptly on hand and brought
the entire ship’s crew of fifteen men safely to shore.
The Dicky was a staunch craft, only a year old, but the terrific
seas soon made a complete wreck of her. She was a very modern
boat and quite up to date in equipment of electric lights, hot and cold
water, and the most valuable piece of her expensive furnishings was
a $12,000 electric engine.
When it was seen that the vessel must speedily break up,
preparations were made to strip from the hull everything of value that
could be moved.
This craft stranded directly in front of a hundred feet high cliff,
and the nearest place at which teams could approach the wreck was
more than two miles at Pamet River Coast Guard Station.
The rigging and sails were quickly taken off, but the great
problem which confronted them was how to land that engine.
At that time Mr. Hayes Small, of the Highland House Hotel,
owned eight powerful horses, and Capt. Pine, of Boston, who had
been sent down by the owners of the craft to take charge, made a
contract with Mr. Small to truck the engine along the beach up
through the Pamet River valley and on to Provincetown.
By lively work on the part of a gang of men the engine was
removed from the vessel to the waiting trucks and four horses pulled
it quickly up the beach and on to destination.
Three days later the Roger Dicky was only a mass of broken
timbers and twisted chains.
Fortunately no lives were lost in this disaster.
THE GETTYSBURG TOW
On the 21st day of June, 1927, the ocean-going tug Gettysburg,
of the Reading Coal Company, towing four empty barges from
Portland for Port Reading, Pennsylvania, was proceeding down the
coast outside of Cape Cod. When the tow had reached a point east
of Race Point Light, the wind, which had been strong from the
northwest, began shifting to the northeast and increasing in violence,
but as it was fair and favorable for running down the coast, the tow
kept on instead of pulling up for Provincetown.
Every moment the wind increased in force, and when the tow
was four miles east of Highland Light the wind had increased to a
strong gale and the sea had become very rough. Suddenly at noon
the hawser holding the tug to the first barge snapped and the four
empty barges comprising the tow were adrift in the raging sea.
Then the tug made strenuous efforts to recover the barges, but
the gale and the sea made this impossible.
All the while the storm and the sea were driving the helpless
barges nearer and nearer to the sea-swept sand bars where they
might be torn to pieces if their keels once touched the bottom. The
crews on the barges, realizing that there was no hope of the tug
being able to recover them, dropped all the anchors with which they
were equipped. This held them, but it was by no means certain that
they would be able to do so if the sea and gale further increased.
Capt. Andrews, of the Highland Coast Guard Station, assembled
his entire crew and they took their life-saving apparatus up to a point
directly opposite the Signal Station of the Weather Bureau on the
Highland Cliffs. The tide was running high and sweeping the entire
foot of the cliffs and it might be a question whether it would be
possible to use the gun and shot line from the shore. So Capt.
Andrews placed part of his crew on the cliffs and the others on the
beach, and there from this point they watched the situation through
the night.
Fortunately the gale did not further increase and by mid-
forenoon of the following day the storm had so far moderated that it
became possible for the tug to return to pick up her barges and
proceed to destination.
The moderating of the gale made it possible to avert what might
have been another death-dealing disaster.

CLIFF WHERE THE COAST GUARD WATCHED THE DRIFTING BARGES


LOSS OF THE ELSIA G. SILVA
The fishing schooner Elsia G. Silva of Gloucester, coming in
from a fishing trip to the South Shoals, off Nantucket, on the
afternoon of February 14th, 1927, encountered a strong wind with
fog when nearing Chatham Bars. This condition grew constantly
worse and the storm increased until it reached gale force, driving a
high sea over the outlying bars, and the thick mist obscured the
shore of the entire coast. The dense fog enveloped everything
except the wildly rushing sea, and before daylight the following
morning the little schooner was borne high upon the crest of the
great white-capped waves, only the next moment to be dashed into
the deep hollows of the gale-swept sea as it rushed onward towards
the beach.
Her crew of sixteen men, with much difficulty and danger, clung
to the rigging of the tossing vessel.
The Coast Guardsmen from Cahoons Hollow Station promptly
reached the vicinity of the wave-swept boat, which soon stranded on
the beach one mile north of the station. They could render no help to
the crew of the Silva by means of boats or gear, and could only
stand by to pull the men from the surf as they were washed from her
decks. One by one the fishermen’s crew were pulled from the surf
until the entire sixteen were safely brought out of the surf that tore
across the doomed craft’s deck.
Soon the fury of the sea tore the vessel to pieces, carrying away
her deckhouses and all movable things from her deck. Soon the
masts fell with a crash into the sea, and sails, rigging and spars
mixed in a jumble of wreckage, and then was scattered along the
sands of the beach. The boat was carrying a fair catch of fish, all of
which was mixed with the wreckage and scattered in the sea.
Soon the men from the village came to the beach and gathered
up such material as had not already been swept far down the coast,
and a few days later only a protruding bit of broken spar or a bit of
rope dangling from some buried anchor marked the spot where the
Elsia stranded.
This again was another fortunate escape of the crew from the
deck of a wrecked vessel; only a little difference in the conditions
might have sent sixteen men to untimely deaths.
A TERRIBLE DISASTER
For several years the Pacific Mail Steamship Company has been
operating a fleet of several large ocean liners, each bearing the
name of a President of the United States. These ships had been
making around the world trips, and in 1927 one of these ships, the
Presidente Wilson, was under charter to the Cosulich Line, an Italian
company.
In the autumn of 1927, the Presidente Wilson was returning from
an all around the world trip, with a large passenger list and tons of
freight from Europe and the Far East, to Boston. She had left Seattle
quite a number of days before, passed through the Panama Canal,
touched at New York and on to Boston, which would end the trip.
The weather held good until she had reached the vicinity of
Nantucket Shoals, where she ran into a dense fog, making it
necessary to slow down and pick her way through the fog that
enveloped her and covered all the coast.
She left New York on the morning of October 28th, and on the
morning of the 29th, at four o’clock in the morning, she had reached
a point four miles directly east of Highland Light. Out of the thick mist
not a hundred yards away, directly in the ship’s path, loomed the
masts and faint outlines of a fishing schooner, which later proved to
be the Avalon, a vessel of about a hundred tons, with home port at
Gloucester, bound on a fishing trip to the banks. She had left Boston
the afternoon before and was jogging along under short sail waiting
for the fog to lift. She was under such small amount of sail that she
could not have moved had she made the attempt.
The oncoming great ship, towering many feet above her, had no
chance to swing clear of the fishing craft and amid the clanging of
bells, the blast of steam whistles, and the shouts and screams of
those both on the big ship and on the fishing boat, they came
together with a crash. The momentum of the huge craft carried her
right on over the Avalon and sent her, broken and wrecked, to the
bottom of the sea, carrying with her nearly all of her crew, who were
imprisoned in her cabin. From the time of the crash until she had
disappeared beneath the sea, there had been no time for the crew to
escape.
The Avalon had a crew of sixteen men and only three of them
escaped with their lives, these three being the deck watch at the
time. The other thirteen were in their bunks and had no chance to
get to the surface before death overtook them.
Boats from the ship were promptly put over and with those of
other vessels which happened to be nearby cruised about the waters
for several hours, but no other man of the fishing boat crew was
recovered.
An hour after the disaster, the fog which had been responsible
for this tragedy cleared all away, the sun shone brightly and the blue
waters of the sea rolled smoothly on. The big liner steamed away on
her course and thirteen unfortunate sailors lay dead on the bottom of
the sea.
Those who go down to the sea in ships do not know what may
be in store for them.
TERRIBLE SUBMARINE DISASTER
A certain section of the waters in and around Provincetown
Harbor have for several years been used as the testing ground for
new or reconditioned submarines of the U. S. Navy.
Early in December of 1927, the submarine S-4 was at this
testing ground, standardizing her engines following some changes
which had been completed at the Charlestown Navy Yard. Her
complement of forty officers and men were on board, and two civilian
visitors.
In the early afternoon of December 17th this submarine went
under to test some part of her machinery and a little workout, and
steamed submerged out of the harbor; when about half a mile south
of the Wood End Lighthouse, and directly in the channel for vessels
leaving or entering the harbor, started to come to the surface. Just at
this moment, coming in from a patrol cruise along the coast, came
the Coast Guard cutter Paulding, steaming for an anchorage in the
harbor at a sixteen miles an hour speed, and crashed with great
force into the side of the submarine, just breaking the surface water.
The sharp iron stem of the Paulding tore a great ragged hole in the
side of the S-4, just forward of the conning tower, and passed
completely over her. The torrent of water which poured through this
hole sent the under-sea boat to the bottom of the sea in five minutes,
with her crew of forty-two imprisoned in her iron hull, with walls that
barred their escape from certain death. Caught like rats in a trap
without the possibility or hope of escape, they were sealed up in their
coffin more than one hundred feet beneath the sea.
When this disaster became known, and it was within five minutes
of the crash, radio and wireless messages sent it to every section of
the country. It sent a thrill of horror to every point the news had
reached; the awful tidings were broadcast to the whole country and
even to points in Europe.
Every available means of possible rescue were hurried to the
scene. A dozen deep sea divers were rushed by train and auto from
New London. Provincetown was the nearest point of approach to the
location of the disaster. Big ships and tugs carrying chains and
appliances were rushed forward by every available means, hoping to
accomplish something towards raising the sunken boat before all her
officers and men had perished by drowning or suffocation.
There was hope that at least some of the men might have been
able to close the watertight compartments before they were
overcome by the inrushing current.
Many kinds of appliances were hurried to the locality by fast
ships; many tugs and steamers gathered over the place where the
S-4 lay at the bottom of the sea off Long Point. Over the sunken boat
white-capped waves were breaking, forced over the surging waters
of the bay by a thirty-mile northwest gale.
As soon as the divers reached the locality a man was sent down
and succeeded in placing a chain over the bow of the submarine;
they had hoped to raise the bow enough to tip the bow towards the
surface, but failed to offer any help.
Again a man was sent down with a hammer, and instructed to
pound along the iron sides of the sunken boat; if he got any
response from the inside it would indicate that there was life there.
The diver when a short distance forward of the locality of the
conning tower and the great hole which had been torn open by the
Paulding when she overwhelmed the under-sea boat, heard a
responsive tapping from the inside. Then the diver tapped out in the
telegraph code, “Are you alive.” The answer quickly came back,
“Yes, six of us are alive here.” Again the diver tapped, “Everything
possible is being done to help you.” Again from the inside, “The air is
very bad in here, please hurry.” This was Sunday afternoon, twenty-
four hours after the disaster.
When it was found that six men were still alive renewed and
strenuous efforts were made to reach the men. All day Sunday and
all Sunday night a hundred men with such appliances as it was
possible to get, labored to bring the bow of the boat to the surface.
Late in the afternoon of Sunday a diver went down and in
response to his tapping found that the six men were still alive, but
they signalled, “We are still alive but growing weaker. We cannot
stand it much longer. Please hurry.”
The diver’s tapping along all other parts of the ship obtained no
other response.
The other men on the boat had been imprisoned either in the
engine room or the after compartments and were all probably
drowned when the ship went to the bottom.
Monday morning brought no change or any hope of relief. The
northwest gale had become bitterly cold, and it was more and more
certain that not a man on the boat was alive, as these men had been
entombed more than forty-eight hours, so the probability or even
possibility of any man being alive down there a hundred feet under
the sea was remote indeed.
What still further added to the horror of the situation, the
increasing cold and freezing winds drove the rescuers from their
work, because it was impossible to send divers down. By this time
the imprisoned men had been so long in their iron coffin, it was not
possible that human life could endure for that time or withstand the
terrible conditions.
Sunday night two monstrous pontoons were brought to the
scene, hoping by their use the bow of the boat might be brought to
the surface. These pontoons were brought from New London by four
powerful tugs, through the Cape Cod Canal, but this was
unavoidably slow on account of the unwieldy shape of the tow and
there was no hope that these pontoons could reach the spot until it
was too late.
Eight skilled divers were already on the scene. Diver Thomas
Eadie went over the side earlier in the day and it was he who was
able to communicate with the entombed men by means of the
hammer tapping signals.
The last signals tapped from the inside of the ship were, “How
long will you be now, hurry.”
Late Sunday P. M. diver Michaels heard from the dying men,
“We cannot live beyond six o’clock.”
In some way this diver’s life line became entangled in a part of
the ragged hole in the hull, and though he struggled frantically to
clear himself, after he had been down more than half an hour it
became evident that something was wrong. Then diver Eadie, with a
hack saw, went down and found Michaels badly tangled in projecting
bits of broken iron of the hull, and it required another half hour for
Eadie to saw off the piece of iron that held Michaels. He had been
held there more than two and a half hours and another half hour
would have resulted in his death. He was hurried to a hospital in
Boston and was ill for some time.
Up to this time every effort to raise the boat or rescue any one of
her crew had utterly failed and some of the boats and gear departed
for other duties.
The attempts to rescue these imprisoned men encountered
awfully adverse conditions.
This disaster happened on Sunday, on that afternoon, and on
Monday, the next day, had there been adequate saving appliances at
hand it is believed some of the men might have been saved, but it
required so much time to get them on the ground that all attempts
were futile.
Another case where men have gone down in the deep sea in a
vessel that was the meanest type of craft ever conceived by man.
Forty good men sent to untimely graves because someone failed
to observe proper care.

“Theirs not to reason why,


Theirs but to do or die,
Somebody blundered.”

What a miscarriage of justice this building of this type of vessel


is. If these vessels are built for fighting purposes, it is an uncivilized
method of warfare and every nation on the earth should be barred
from building another submarine. Already we have sent the
battleships to the scrapheap. By all means send the submarine to
join them.
In regard to the wretched lack of proper appliances for handling
such a terrible disaster, we see one more tragedy. Men familiar with
submarines, their building and handling, declare that it was a case of
criminal carelessness on the part of the Government and the Navy
Department in particular.
Secretary Wilbur, of the United States Navy, visited the locality of
the disaster and ordered that the work of salvaging the submarine
and bringing out the bodies must proceed until every one is brought
to shore.
On the 4th day of January three bodies were recovered from the
engine room of the under-sea boat and in time the others in the after
compartments will be brought to the surface.
Representative Gifford came on from Washington to learn from
personal observation if everything possible had been done to save
the men from their coffin.
Among the crew of the S-4 when she went down was a seaman
by the name of Walter Bishop. He had previously been on a
submarine when an accident happened, and among his effects, left
with relatives, was found a poem of thirteen verses, in which he
described the situation and conditions on these ships in full detail.
We have room for only the first verse, which certainly hits the mark.

“IN THE CANKEROUS MIND OF THE DEVIL,


THERE FESTERED A FIENDISH SCHEME,
HE CALLED HIS COHORTS TOGETHER,
AND THEY DESIGNED THE SUBMARINE.”

The time having long passed when it was possible for any
human being to be alive, the only thing to do was to some day raise
the boat to the surface.
Submarines have figured in some of the most awful tragedies of
modern times. Only a partial record is available, but a recent
statement of the story discloses that no less than 295 human beings
have gone to death in submarines in the last decade.
In 1923 a Japanese boat carried down to death eighty-five
persons. In 1925 the No. 51 with thirty-three men, and now the S-4
with forty.

THE MUTE REMAINS OF A TRAGEDY OF THE SEA


STRANDING OF THE ROBERT E.
LEE
On the afternoon of March 9th, 1928, a northeast wind pushed in
from the sea and by five P. M. it had developed into a howling gale
with blinding snow. Out from her home dock at India Wharf in Boston
the big passenger and freight boat Robert E. Lee pulled out for her
trip to New York, via the Cape Cod Canal. The storm instead of
diminishing grew constantly worse, but she ploughed her way
through the wildly rushing sea, and though only two miles from the
beach along the Manomet and Sandwich shores not a glimpse could
be had of the land through the snow filled air, and navigation became
a matter of dead reckoning and a hope to pick up the lighthouse at
the Cape Cod Bay entrance of the Canal.
When the ship had reached a point about two miles from the
Canal entrance she crashed with terrific force upon the rocks of a
projecting ledge and was there held fast on the “Mary Ann Rocks,” a
short distance south of the Manomet Coast Guard station. This
found the Robert Lee in a most dangerous position, where the great
seas driving straight across Cape Cod Bay swept the ship from stem
to stern. The ship carried 150 passengers and a crew of 110.
S. O. S. calls were quickly sent out and Coast Guard and Naval
boats hurried to the scene.
The Coast Guard boats from Gurnet, Manomet, Sandwich and
Provincetown were promptly brought into service, but as the
conditions of wind and sea were so dangerous it was not deemed
advisable to attempt the transfer of the passengers from the
stranded ship just then.
Towards morning the fury of the gale having subsided the work
of taking off the passengers began, and was successfully
accomplished a few hours later with no serious mishap to the
passengers and the ship’s crew remained on board. But the affair
was not to escape without the tragedy of the loss of human lives.
The Coast Guard boat of the Manomet Station in trying to make
connection with the stranded steamer, was caught under the bow by
a huge sea that swept fiercely around the counter of the Lee, turned
the boat completely over and sent her crew of eight men helplessly
into the sea, four of them clung desperately to the overturned boat,
the other four struck out in an attempt to reach the shore, but those
clinging to the boat and those fighting for the shore were finally
rescued. But those from the overturned boat were so thoroughly
chilled and exhausted that they were immediately hurried to Chelsea
Hospital where three of them died.
If there are people who think that the men who man the stations
along our storm swept coasts have a sinecure, would they like to
have been in the Manomet surf boat that day?
Many names of heroes are emblazoned upon the scroll of
human endeavor the world over but there are deeds equally as
deserving of record that pass unnoticed and unsung.
The recent disaster on the rocks at Manomet brought
prominently before us several instances of unselfish heroism, not on
bloody fields of battle, but in the freezing waters of the cruel sea.
Not detracting in the least from the brave efforts of the Coast
Guardsmen, three of whom gave up their lives in the struggle, or the
men and boy who pushed out in small and leaking boats to help,
there was one case of glorious heroism that stands out preeminently,
and whose name should stand high up on the roll of honor, and that
is Ernest Douglas, a man unskilled in the use of boats, but he
stripped from his clothing his money and watch, handed them to a
friend, and as he sprang into the surf boat to take the place of an
absent member of the Surf Boat crew, called back to his friend on
shore, “If I do not come back give them to my wife.”
We are glad to record that he did come back safely.
Transcriber’s Notes
Punctuation, hyphenation, and spelling were made
consistent when a predominant preference was found in the
original book; otherwise they were not changed.
Dialect spellings were not changed.
Simple typographical errors were corrected; unbalanced
quotation marks were remedied when the change was
obvious, and otherwise left unbalanced.
Illustrations in this eBook have been positioned between
paragraphs and outside quotations. In versions of this eBook
that support hyperlinks, the page references in the List of
Illustrations lead to the corresponding illustrations.
*** END OF THE PROJECT GUTENBERG EBOOK SHIPWRECKS
ON CAPE COD ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright
in these works, so the Foundation (and you!) can copy and
distribute it in the United States without permission and without
paying copyright royalties. Special rules, set forth in the General
Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like