Share E-Book
Scan to open this page

Scan with your phone to open this page

AuthorAlice Zhao

If you use SQL in your day-to-day work as a data analyst, data scientist, or data engineer, this popular pocket guide is your ideal on-the-job reference. You'll find many examples that address the language's complexities, along with key aspects of SQL used in Microsoft SQL Server, MySQL, Oracle Database, PostgreSQL, and SQLite. In this updated edition, author Alice Zhao describes how these database management systems implement SQL syntax for both querying and making changes to a database. You'll find details on data types and conversions, regular expression syntax, window functions, pivoting and unpivoting, and more. • Quickly look up how to perform specific tasks using SQL • Apply the book's syntax examples to your own queries • Update SQL queries to work in five different database management systems • NEW: Connect Python and R to a relational database • NEW: Look up frequently asked SQL questions in the "How Do I?" chapter

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A compact, cross-database reference that turns "how do I write this in SQL?" into a quick lookup: one task per entry, with syntax shown side by side for SQL Server, MySQL, Oracle, PostgreSQL, and SQLite. Best for analysts, data scientists, and data engineers who already know some SQL but keep hitting dialect differences. 【Book Arc】 - **Opening (~0%–10%)**: Orients you before any syntax — what a database, table, column, primary key, foreign key, and relationship are, plus a comparison of the five RDBMSs (owner, open vs. proprietary, typical platform and companion tools). Solves the "which system am I actually writing for?" problem. - **Early (~10%–30%)**: Language fundamentals and querying basics — keywords vs. functions, case-insensitivity, comments, quotes, NULL handling, and the six main clauses in execution order (SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY), including WHERE vs. HAVING and subqueries. - **Early–Middle (~30%–50%)**: Making changes — creating databases and tables, constraints, primary/foreign keys, auto-generated ID fields, loading data from text files, INSERT/UPDATE/DELETE, indexes, views, and transactions as all-or-nothing units. - **Middle (~50%–65%)**: Data types and conversion — numeric, string, datetime, and other categories; literals and constants; how each RDBMS represents and converts values, including signed vs. unsigned integer ranges. - **Late (~65%–90%)**: The dialect-heavy material the book is known for — regular expression syntax, window functions, and pivoting/unpivoting, each shown per RDBMS. - **Ending (~90%–100%)**: Practice-oriented extras — connecting Python and R to a relational database, and a "How Do I?" chapter of frequently asked SQL questions for fast lookup. 【Key Takeaways】 - **The book's core value is dialect translation, not SQL theory** (Opening): the same task is presented across five RDBMSs, so you can port a query rather than guess at syntax. - **Clause execution order explains common errors** (Early): SELECT is written before HAVING but executed after it, which is why HAVING cannot reference a SELECT alias — a small fact that resolves a lot of confusion. - **WHERE filters rows, HAVING filters aggregations** (Early): the two are not interchangeable; putting an aggregate condition in WHERE errors out, and non-aggregate conditions in HAVING are simply inefficient. - **Subqueries exist to decompose problems** (Early): either to chain steps (compute per-group values, then aggregate them) or to shrink an unwieldy FROM source before the outer query runs. - **Schema design decisions are made at CREATE TABLE time** (Middle): constraints, composite primary keys, matching foreign-key data types, and auto-generated ID columns all have per-RDBMS variations worth checking before you build. - **UPDATE and DELETE without WHERE are table-wide operations** (Middle): the book flags this explicitly — the SET clause needs a WHERE partner whenever you intend to touch specific rows. - **Transactions make multi-statement changes atomic** (Middle): either all statements run or none do, and you can inspect effects before committing — the safety net for risky edits. - **Data types and NULL semantics differ by system** (Middle): missing values in loaded CSV files, NULL comparisons (IS NULL, never = NULL), and signed/unsigned ranges are all places where portability breaks. - **The new editions extend beyond pure SQL** (Ending): Python and R connection workflows, plus a "How Do I?" lookup chapter, push the book toward day-to-day workflow reference. 【Reading Tips】 - **Use it as a lookup, not a cover-to-cover read.** The preface and Chapter 1 comparison table are worth reading once; after that, jump straight to the task entry you need. - **Deep-read the dialect tables.** When a task has five side-by-side versions, read all five even if you only use one — that is where the book earns its keep and where portability surprises hide. - **Skim the fundamentals if you already write SQL.** Keywords, comments, and quotes are refreshers; spend the saved time on window functions, regex, and pivoting. - **Treat warnings as the highest-value lines.** Notes on UPDATE/DELETE without WHERE, Oracle's case-sensitive table names, and MySQL's local data loading flag are the errors you will actually hit. - **Keep the "How Do I?" chapter as your first stop** for recurring questions before searching the web. 【Coverage Limits】 This guide is built from stratified excerpts covering the preface, table of contents, RDBMS comparison, core querying, table modification, data types, and connection setup; the excerpts do not cover the detailed contents of the regex, window function, pivoting, or "How Do I?" chapters, so those are described by topic rather than by specific technique.
Page 7
97 Create a Simple Table 98 Display Names of Existing Tables 100 Create a Table That Does Not Already Exist 100 Create a Table with Constraints 101 Create a...
View in text
Excerpt 2
nloads page. RDBMS Software | 17 Database Connection Fields To connect to a database, you’ll need to fill out the following fields within a database tool: Ho...
View in text
Excerpt 3
ge 88 in this chapter for more details. The GROUP BY Clause The purpose of the GROUP BY clause is to collect rows into groups and summarize the rows within t...
View in text
Excerpt 4
3 CA Michael 4 4 US Stefani 9 126 | Chapter 5: Creating, Updating, and Deleting The order of the columns matters here. If you write a query that filters on:...
View in text
Excerpt 5
er: SELECT * FROM employees WHERE manager IS NOT NULL; LIKE Use LIKE to match a simple pattern. The percent sign (%) is a wildcard that means one or more cha...
View in text
Excerpt 6
| 1 | hi there | | 2 | hello! | | 3 | NULL | When there is no greeting, return hi: SELECT COALESCE(greeting, 'hi') AS greeting FROM my_table; | greeting | |...
View in text
Excerpt 7
JOIN links together multiple tables within a single query, whereas UNION stacks the results of multiple queries: -- JOIN example SELECT * FROM birthdays b JO...
View in text
Excerpt 8
table expres‐ modifying in a table, 122 sions) 320 | Index LISTAGG function, 191, 242, 310 from CSV file, interpretations literals, 144 by RDBMS, 114 localho...
View in text
Tags
AI categories
DatabaseSQLData
ISBN: 1492090409
Publisher: O'Reilly Media
Publish Year: 2021
Language: English
Pages: 356
File Format: PDF
File Size: 6.6 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…