Every professional programmer that accesses data in a relational/SQL database should have a good book (or four) on SQL… Actually, the same goes for DBAs because they also regularly use SQL in their day-to-day work. There are many SQL books to choose from, and many of them are very good. Here are four of my favorites from over the years…
The first SQL book I recommend is SQL Performance Tuning by Peter Gulutzan and Trudy Pelzer. This books offers up a treasure trove of tips for improving SQL performance on all of the major database systems. This book does not teach SQL syntax, but instead helps the reader to understand the differences between the most popular DBMS products, including Oracle, DB2, SQL Server, Sybase ASE, MySQL, Informix, Ingres, and even InterBase.
Throughout this book the authors present and test techniques for improving SQL performance, and grade each technique for its usefulness on each of the major DBMSs. If you deal with heterogeneous database implementations this book will be a great assistance, whether you are a programmer, consultant, DBA, or technical end user. The contents of this book can help you to decide which tuning techniques will work for which DBMS.
My next SQL book recommendation is altogether different in purpose than the first. It is SQL in a Nutshell, by Kevin Kline, Daniel Kline, and Brand Hunt.
This book offers a great cross-platform syntax reference for SQL. It probably is not the easiest reference to use for finding the exact syntax for one particular DBMS; but it is absolutely the best reference for those who work with multiple DBMSs.
Next up is The Art of SQL by Stephane Faroult, which is a guide to SQL written using the approach of “The Art of War” by Sun-Tzu.
The author actually uses the exact same title chapters for The Art of SQL that Sun Tzu used in The Art of War. Amazingly enough, the tactic works. Consider, for example, the chapter titled “Laying Plans,” in which Faroult examines how to design databases for performance. As anyone who ever built database applications knows an improperly designed database can be the biggest impediment to flawless application performance.
The chapter titled “Tactical Dispositions” covers the topic of indexing and in “The Nine Situations” the author examines several calssic SQL patterns and how best to approach them.
This book is not for a novice who wants to learn SQL from scratch. The authors assume the reader is conversant with SQL as they describe how to apply SQL in a practical manner. If you can’t code an outer join or don’t know what a nested table expression or in-line view is, then this is not the book for you.
Neither is the book a list of SQL scripts that you can pluck out and use. Instead, The Art of SQL skillfully manages to explain how to properly attack the job of coding SQL to effectively and efficiently access your data. The book offers best practices that teach experienced SQL users to focus on strategy rather than specifics.
The Art of SQL skillfully manages to explain how to properly attack the job of coding SQL to effectively and efficiently access your data. The book offers best practices that teach experienced SQL users to focus on strategy rather than specifics.” You know, if Sun Tzu coded SQL, he might have written a book like “The Art of SQL”. But since Sun Tzu is dead, I’m glad Stephane Faroult was around to author this tome.
The final SQL book recommendation is the latest edition of SQL for Smarties by the grand master of SQL, Joe Celko. Celko was a member of the ANSI SQL standards committee for ten years, and is highly qualified to write such a text.
The 3rd edition was completely revised and boasts over 800 pages of advanced SQL programming techniques. If you have any of the past two editions of this book, you owe it to yourself to get the newly revised third edition.
This book offers tips, techniques, and guidance on writing effective, sometimes complex, SQL statements using ANSI standard SQL. It touches on topics ranging from database design and normalization to using proper data types to grouping and set operations, optimization, data scaling, and more. Every developer who codes SQL statements for a living will find something useful in SQL for Smarties!
Joe also wrote an introductory SQL book titled SQL Programming Style (Morgan Kaufmann: ISBN 0-12-088797-5) that offers useful guidance on how to write standard SQL. If SQL for Smarties is too much for you, start off with SQL Programming Style.
In all cases, if there is a newer edition of the book than the ones in the links then, by all means, buy the latest edition. These authors have proven themselves to write quality content and I trust that any new edition would improve on their existing material.
Happy SQL coding everybody!