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. *** ½