SQL Advanced Tutorial cover

SQL Advanced Tutorial

Rating 4.5
Word count
214K words
Chapters
24
Series
Turing Programmer Series
ISBN
9787115470522

Tags

Summary

This book is a guide to leveling up your SQL skills, written by MICK, the author of SQL Basic Tutorial and a Japanese database engineer, for readers who want to move from beginner to intermediate level. The book is broadly divided into two parts. Part 1 revisits SQL techniques commonly seen in day-to-day development—CASE expressions, self-joins, the HAVING clause, outer joins, correlated subqueries, the EXISTS predicate, set operations, row-to-row comparison, and working with sequences—and, through numerous sample programs and exercises, explains the easily overlooked uses of these techniques and the logic behind them, helping readers shift gradually from procedural thinking to set-based thinking. Part 2 bridges practice and theory, starting from the history of relational databases and extending to the relational model as seen through set theory and logic, discussing the origin of the name “relational,” the troubles of NULL and three-valued logic, address-type data, hierarchical structures, and other topics, so that readers understand the roots of SQL’s design trade-offs. Most sections end with exercises, and the book closes with answers and references, making it easy for readers to check their own grasp of the material. The book is suited to readers who already have basic SQL knowledge and want to write more concise and efficient queries.

Editor's review

很多 SQL 使用者能写查询,却写不出“漂亮”的查询:明明可以用一个 CASE 表达式解决,却写了三段 UNION;明明一次自连接就能搞定,却把数据拉到应用层循环处理。这本书要纠正的正是这类习惯。MICK 的写法很有特点——每一节先抛出一个真实业务里会遇到的古怪需求,再从常见技术中挖出被忽视的用法,最后附上练习题,让读者自己动手验证。第 1 章的 CASE、外连接、EXISTS、数列处理几乎全是“原来还能这样写”的顿悟时刻;第 2 章转入理论,讲清关系模型、三值逻辑与 NULL 的由来,读完会明白某些写法为何被数据库设计者鼓励、另一些为何要避开。全书篇幅不大,214 千字,但信息密度高,适合边读边在数据库里跑示例。它不教语法入门,而是教判断力——这正是初级与中级之间的那道坎。

Who it's for

A good fit for

  • 有半年以上 SQL 使用经验、已掌握基本语法的开发者
  • 经常写报表查询、需要优化复杂 SQL 的数据分析师
  • 想理解关系模型与集合论基础、准备进阶的后端工程师
  • 把《SQL基础教程》读完、想继续系统提高的读者

Not a good fit for

  • 完全零基础、尚未写过 SELECT 语句的初学者
  • 只想速查某款数据库(MySQL、Oracle 等)方言差异的读者
  • 期待大量大数据或分布式计算框架内容的人

Reading tips

  1. 在第 1 章每节先合上书自己写一遍查询,再对照书中写法,差异处往往就是收获。
  2. 准备一套示例数据并在真实数据库中跑通所有 SQL,注意不同 DBMS 的方言差异与执行计划。
  3. 第 2 章理论部分可放慢速度,配合练习题理解三值逻辑与 NULL 的处理策略。
  4. 读完后把书中的技巧回头套用到自己项目里最慢的几条查询上,做一次实际改写。

About the publisher

Posts & Telecom Press China · Founded in 1953

Posts & Telecom Press is known for its strengths in science and technology, computing, and information and communications titles, and has extended its publishing into photography, art, software learning, and inspirational growth, giving it a fairly diverse range. Its catalog includes computing and communications works such as Refactoring and Patterns (Revised Edition) and Huawei Switch Learning Guide (Second Edition), alongside bilingual collector's editions such as The Little Prince (Chinese-English-French illustrated collector's edition), The Great Gatsby, and Three Days to See. Beijing Ten Years: 1980-1990 and Ghost Blade: WLOP Personal Illustration Collection reflect its presence in photography and art. Its authors include Antoine de Saint-Exupéry, Helen Keller, Joshua Kerievsky, Wang Da, Zhang Zhaozeng, and WLOP.

Contents

  1. Chapter 1 The Magic of SQL
  2. 1-1 CASE Expressions
  3. 1-2 Using Self-Joins
  4. 1-3 Three-Valued Logic and NULL
  5. 1-4 The Power of the HAVING Clause
  6. 1-5 Using Outer Joins
  7. 1-6 Comparing Rows with Correlated Subqueries
  8. 1-7 Set Operations in SQL
  9. 1-8 Using the EXISTS Predicate
  10. 1-9 Working with Sequences in SQL
  11. 1-10 The HAVING Clause Returns
  12. 1-11 Making SQL Fly
  13. 1-12 Methods of SQL Programming
  14. Chapter 2 The World of Relational Databases
  15. 2-1 The History of Relational Databases
  16. 2-2 Why Is It Called the “Relational” Model?
  17. 2-3 Starting with Relations, Ending with Relations
  18. 2-4 Address: The Great Monster
  19. 2-8 Human Logic
  20. 2-9 The Committee to Eliminate NULL
  21. 2-10 Hierarchies in SQL
  22. Chapter 3 Appendix
  23. 3-1 Exercise Answers
  24. 3-2 References

FAQ

这本书适合零基础学 SQL 的人吗?
不适合。本书定位是中级进阶,默认读者已掌握 SELECT、JOIN、子查询等基础语法。零基础建议先读同作者的《SQL基础教程》,再回到本书。
这本和《SQL进阶教程(第2版)》有什么区别?
本页信息对应 2017 年首版(ISBN 9787115470522,吴炎昌译,约 301 页)。2023 年人民邮电出版社推出第 2 版(ISBN 9787115609762),由吴炎昌、侯振龙合译,新增窗口函数等内容,篇幅增至约 336 页,两版并非同一本书。
书中的 SQL 能直接在自己的数据库里运行吗?
书中示例以标准 SQL 为主,多数语句可在 PostgreSQL、MySQL、Oracle 等常见数据库中运行,但窗口函数、日期函数等细节存在方言差异,建议按所用 DBMS 做小幅调整后验证。
这一版有配套资源或习题答案吗?
书末第 3 章即“习题解答”,收录了各节练习题的参考答案,并附参考文献。示例数据库结构可在阅读时按书中说明自行搭建,或参考图灵社区相关配套资料。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

More by the same author

Top rated in the same category