What do you think?


Joe Celko's SQL for Smarties: Advanced SQL Programming
In the SQL database community, Joe Celko is a well-known columnist and purveyor of valuable insights. In Joe Celko's SQL for Smarties: Advanced SQL Programming, he picks up where basic SQL training and experience leaves many database professionals and offers tips, techniques, and explanations that help readers extend their capabilities to top-tier SQL programming.
Although Celko denies that the book is about database theory, he nevertheless alludes to theory often to buttress his practical points. This title is not for novices, as the author points out. Instead, its intended audience is SQL programmers with at least a year's experience. The book maintains a fine balance between technical discussion and practical explanation--picking hot topics and offering advice on a wide range of issues.
The book uses ANSI SQL-89 as its baseline standard, with some mention of SQL-92 features. It does not, however, focus on any commercial product; this guide zeroes in on the SQL language. Celko covers all aspects of database design, optimization, and manipulation, with easy-to-understand explanations of key issues such as why not to use too many nulls, how to use practical normalization, and how to optimize queries.
This insightful text is manna for all the day-to-day SQL coders banging their heads over the language's subtle challenges. --Stephen W. Plain
Topics covered: Database design and normalization, SQL data types, querying, grouping, set operations, optimization, data scaling, and encoding.
467 pages, Paperback
First published January 1, 1995
Ratings & Reviews
Friends & Following
Create a free account to discover what your friends think of this book!
Community Reviews
Displaying 1 - 16 of 16 reviews
September 15, 2019
I found it an easy read, common sense and with numerous useful examples. I won't offer up the cliche that more deveolpers should read this book but will offer up the suggestion that more of them follow up by implementing it's suggestions.Really ENJOYED it, it was surprisingly easy to read. Explained all the rules and principles well. I was thinking about our production code all the time while reading it.
September 19, 2019
A must-read for every programmer! Most of the BOOKS teach you how to program, or how to use your specific language features, but none of them will teach you how to actually write clean and manitainable code. This one does!
July 20, 2017
This book seems much better than the other Celko books I've read or browsed- not surprising since its his core, original book.
The good:
It covers a wide range of topics, including detailed examples of many interesting niche cases.
Celko doesn't seem to be as much of a jerk as in the other two books I've read (SQL Programming Style and Thinking In Sets).
I think this book gave decent coverage of everything in those other two books- I'm not sure they really need to exist at all. He does regularly call out when there is more coverage available in a specific book, and that may make sense in other cases.
The meh:
Lots of repetition (but if you want to use it as an occasional reference, that may be good).
Examples tend to switch between several different formats (sometimes the schema is illustrated with data, sometimes with CREATE statements, only occasionally is result data shown), and it doesn't seem to be a conscious choice.
Physical formatting could be a lot better- often a huge margin sits next to lines of code that wrap unnecessarily.
And he frequently uses the !@#$ing pre-ANSI-99 join criteria syntax, just like some of my !@#$ Oracle-centric co-workers.
The good:
It covers a wide range of topics, including detailed examples of many interesting niche cases.
Celko doesn't seem to be as much of a jerk as in the other two books I've read (SQL Programming Style and Thinking In Sets).
I think this book gave decent coverage of everything in those other two books- I'm not sure they really need to exist at all. He does regularly call out when there is more coverage available in a specific book, and that may make sense in other cases.
The meh:
Lots of repetition (but if you want to use it as an occasional reference, that may be good).
Examples tend to switch between several different formats (sometimes the schema is illustrated with data, sometimes with CREATE statements, only occasionally is result data shown), and it doesn't seem to be a conscious choice.
Physical formatting could be a lot better- often a huge margin sits next to lines of code that wrap unnecessarily.
And he frequently uses the !@#$ing pre-ANSI-99 join criteria syntax, just like some of my !@#$ Oracle-centric co-workers.
January 21, 2014
Because of its author, this book has some reputation out there. I read through part of it at the time when I started, and never finished it. The book gives some interesting thoughts about SQL. But the code examples are not too useful since there are a lot of errors..
February 15, 2023
This book is rightfully known as the book on SQL Programming - and rightfully so. Obviously the author is extremely knowledgable on the subject, and his time on the SQL Standards committee is obviously well reflected in this book. I have also read a few of his other books, notably Joe Celko's Trees and Hierarchies in SQL for Smarties, and I particularly like the balance of formal teaching, practical tips, and several examples.
However, that said, I had to take away a star in my review. When a topic that is covered in another book is reprinted in this one, it makes sense, and hopefully encourages readers to explore some of the other books in greater detail. But, especially towards the back quarter of the book, there were several sections reprinted in verbatim (the first example that comes to mind is the DATE TIME section (~ ch9) in the Temporal Queries section (Ch 35). I get that perhaps some people would view this book as a "cookbook" style text - but it would be much better if the author would have just pointed the reader to the prior section. Also, while I did not reduce my rating, towards the end of the book the editing seems to get a bit lax.
Stylistic complaints aside, this book is a gold mine of information, and I strongly recommend people who are interested in developing some SQL skills to check it out.
However, that said, I had to take away a star in my review. When a topic that is covered in another book is reprinted in this one, it makes sense, and hopefully encourages readers to explore some of the other books in greater detail. But, especially towards the back quarter of the book, there were several sections reprinted in verbatim (the first example that comes to mind is the DATE TIME section (~ ch9) in the Temporal Queries section (Ch 35). I get that perhaps some people would view this book as a "cookbook" style text - but it would be much better if the author would have just pointed the reader to the prior section. Also, while I did not reduce my rating, towards the end of the book the editing seems to get a bit lax.
Stylistic complaints aside, this book is a gold mine of information, and I strongly recommend people who are interested in developing some SQL skills to check it out.
August 3, 2019
This book really opened my eyes to the value of DBMS software provided by Oracle. Trying to implement some Oracle functionality with pure ANSI SQL is painful but enlightening.
March 21, 2025
Good for general SQL, however a bit out-dated, some SQL execution engines have been improved since the book release. Also this focus more on standard SQL than e.g. T-SQL.
March 27, 2014
Joe Celko, SQL for Smarties 4/E (Morgan Kaufmann, 2011)
Full disclosure: a copy of this book was provided to me free of charge by Amazon Vine.
It had been a very long time since I had updated the Duration column on my spreadsheet, but I figured if any book warranted doing so, it would be SQL for Smarties. I knew it had taken me a long, long time to get through it (it sat on my desk at work for quite a while and I had no time there to get to it), but even I didn't know how long specifically. As of this writing, it is the third-longest I have ever taken to read a book—from first page to last, 1,062 days. (#2 is a book that had gone back to the library for three years before I took it out again; #1 is a book that got lost for four years before I stumbled upon it in a box and finished it up within the week.) That is one heckuva lot of time for a book, but then SQL for Smarties is not normally the kind of book one reads from beginning to end anyway, so take all that with a grain of salt.
The bad part: there are long stretches of it that are pretty dry. Celko has been a member of many of the SQL standards committees, and quotes at length from the documents he helped to author for them. For some people, that might be a great way to learn. Me, I'm a big fan of examples, and lots of them, and they do show up in almost every section; I would've liked a stronger focus on practice than theory, but well, YMMV, and probably will. This is balanced out by the fact that when Celko lets his (non-existent) hair down, every once in a while a sentence will pop out that you can't believe you just read in what is, essentially, a technical manual, and those sorts of little surprises may seem like throwaways, but for someone like me, they add a lot of intangible value; this one will be a ref manual on my shelf after a lot of other ones have fallen by the wayside.
The other drawback, and this was a consciously-planned one on Celko's part, is that the book is language-pure, which pretty much by definition in today's world means implementation-agnostic. Which is not a bad thing on the theory level, but can be nightmare in practice if you straddle a couple of database lines. I work with both T-SQL and MySQL, and more than once I've found myself doing something like saying “well, why aren't we using a LIMIT statement there?” when talking about a stored procedure in T-SQL. “See? Right here in Celko...”, and then we actually try it and Microsoft borks because LIMIT doesn't exist in T-SQL. (Hey, Microsoft, fix that, it's an amazing function.) To be fair to Celko, he throws in an admonition about that every so often, but that won't combat wishful thinking.
On the other hand, the big, big upside is that as long as you keep the above caveats in mind, SQL for Smarties is really the only SQL reference book you'll ever need (pending new editions, of course); it may not be exhaustive—I think I remember Celko saying that once or twice—but it's pretty comprehensive, it dives into nooks and crannies that most people will never explore (even if they should), it addresses not only the way the language should be used but the ways it shouldn't (and is often pressed into service to do anyway), etc. There is a massive wealth of information here for database developers who use a flavor of SQL, and it belongs on the shelf of every person who fits that description, amateur or professional. *** ½
Full disclosure: a copy of this book was provided to me free of charge by Amazon Vine.
It had been a very long time since I had updated the Duration column on my spreadsheet, but I figured if any book warranted doing so, it would be SQL for Smarties. I knew it had taken me a long, long time to get through it (it sat on my desk at work for quite a while and I had no time there to get to it), but even I didn't know how long specifically. As of this writing, it is the third-longest I have ever taken to read a book—from first page to last, 1,062 days. (#2 is a book that had gone back to the library for three years before I took it out again; #1 is a book that got lost for four years before I stumbled upon it in a box and finished it up within the week.) That is one heckuva lot of time for a book, but then SQL for Smarties is not normally the kind of book one reads from beginning to end anyway, so take all that with a grain of salt.
The bad part: there are long stretches of it that are pretty dry. Celko has been a member of many of the SQL standards committees, and quotes at length from the documents he helped to author for them. For some people, that might be a great way to learn. Me, I'm a big fan of examples, and lots of them, and they do show up in almost every section; I would've liked a stronger focus on practice than theory, but well, YMMV, and probably will. This is balanced out by the fact that when Celko lets his (non-existent) hair down, every once in a while a sentence will pop out that you can't believe you just read in what is, essentially, a technical manual, and those sorts of little surprises may seem like throwaways, but for someone like me, they add a lot of intangible value; this one will be a ref manual on my shelf after a lot of other ones have fallen by the wayside.
The other drawback, and this was a consciously-planned one on Celko's part, is that the book is language-pure, which pretty much by definition in today's world means implementation-agnostic. Which is not a bad thing on the theory level, but can be nightmare in practice if you straddle a couple of database lines. I work with both T-SQL and MySQL, and more than once I've found myself doing something like saying “well, why aren't we using a LIMIT statement there?” when talking about a stored procedure in T-SQL. “See? Right here in Celko...”, and then we actually try it and Microsoft borks because LIMIT doesn't exist in T-SQL. (Hey, Microsoft, fix that, it's an amazing function.) To be fair to Celko, he throws in an admonition about that every so often, but that won't combat wishful thinking.
On the other hand, the big, big upside is that as long as you keep the above caveats in mind, SQL for Smarties is really the only SQL reference book you'll ever need (pending new editions, of course); it may not be exhaustive—I think I remember Celko saying that once or twice—but it's pretty comprehensive, it dives into nooks and crannies that most people will never explore (even if they should), it addresses not only the way the language should be used but the ways it shouldn't (and is often pressed into service to do anyway), etc. There is a massive wealth of information here for database developers who use a flavor of SQL, and it belongs on the shelf of every person who fits that description, amateur or professional. *** ½
September 10, 2019
It's close to Mark Lutz's "Learning Python", which means that it's close to be apalling.
Very inconsistent, with broken (i.e., unreproducible) and didactic examples, overly abstract, bloated, etc.
I've plowed through it with difficulty a couple of years ago, and still have the feeling that I've wasted my time.
IMHO, it's better to read 2-3 smaller and practical books, then waste your time on this one.
Very inconsistent, with broken (i.e., unreproducible) and didactic examples, overly abstract, bloated, etc.
I've plowed through it with difficulty a couple of years ago, and still have the feeling that I've wasted my time.
IMHO, it's better to read 2-3 smaller and practical books, then waste your time on this one.
July 16, 2008
目標:盆休み中に読了。
June 4, 2010
Good, but a bit over-rated. Some of the code in here is a bit obscure and most would probably have trouble finding use for it on everyday projects. Still neat, though.
September 21, 2011
Extremely obscure geeky stuff. This is not the stuff you use every day.
December 3, 2012
Somehow it doesn't cover the real challenges in writing SQLs.
December 9, 2012
You will learn a lot by reading this book if you have a basic grounding in SQL and are looking to stretch yourself to solving the most difficult SQL problems in a set-oriented way.
June 11, 2013
This book taught me everything that i needed to know about databases.
Want to Read
July 6, 2013How to read this
Displaying 1 - 16 of 16 reviews














