Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!


Forgot your password?

SQL Pocket Guide, Second Edition 50

Graeme Williams writes "So many dimensions are folded into this compact book that it took me more than a few moments to see what I was looking at. In the space of 184 pages, SQL Pocket Guide, Second Edition documents, explains, illustrates and compares the most common SQL statements from Oracle (10g), DB2 (8.2), SQL Server (2005), MySQL (5.0) and PostgreSQL (8.1), with occasional notes on previous versions, and pointers to more material on the author's web site. The book bills itself as "A Guide to SQL Usage" and it has an ample amount of explanatory material in addition to syntax and examples." Read the rest of Graeme's review.
SQL Pocket Guide, Second Edition
author Jonathan Gennick
pages viii + 184
publisher O'Reilly Media
rating 10
reviewer Graeme Williams
ISBN 0-596-52688-1
summary A clear and compact overview of SQL for five different databases

The second edition of SQL Pocket Guide has been updated for the latest versions of the four databases covered in the first edition, and PostgreSQL has been added. There are also new sections on datatypes and creating tables and indexes. O'Reilly has recently announced that all of their pocket guides and references will be available as PDFs. This review is based on the paper book.

In addition to the most common SQL statements, SQL Pocket Guide, Second Edition also describes many useful functions, including datatype conversions, date/time, math, trig and string functions, and handling nulls. The table of contents for the book provides an excellent idea of what is included. One note about the table of contents: sometimes differences in syntax between different databases are covered inline, and sometimes each database is covered in a separate subsection. The table of contents makes the two types of coverage clear, since a subsection for a particular database is indicated by the database name in parentheses, such as "Numeric Conversions (Oracle)".

Rather than give formal syntax specifications, Gennick gives examples for each statement and function that he explains. The neat thing is that all the examples run against a simple schema and data which you can download from the book's web page. And yes, the data comes in five flavors to match the five databases covered by the book. You shouldn't underestimate how much this buys you in maintaining the book's high information density. It means that the SQL examples can be presented, and make sense with, little or no lead in.

Gennick also includes some pointers to the material on his web site. If you regularly lose bar bets on the details of recursive queries, or you need more explanation than the book provides, this will be very useful.

SQL Pocket Guide is organized alphabetically by topic, such as "Selecting Data", "Subqueries" or "Tables, Creating". Each topic is divided into a number of sections, such as SELECT, FROM and WHERE and again into subsections, such as specifying a table alias in the FROM clause. I like the size of the book (4 1/4 in. by 7 in.). The fact that the pages are pretty small, however, means that two facing pages might only contain a few subsections without any indication of the section they belong to. This can make it hard to keep track of context while flipping through pages. It's needlessly hard to distinguish between topic, section and subsection headings because they're all in the same font, and only a point or two different in size. There ought to be some simple way to indicate the difference.

I don't mean to suggest that the book is impenetrable. The table of contents includes both topic and section headings, and it's easy to skim to find what you're looking for. The topic is given at the bottom of every right-hand page. It would be great if the section was given at the bottom of every left-hand page, which is presently wasted by repeating the book title.

SQL Pocket Guide is small and clear. If you're looking for a book that is small, clear and complete, I'm sorry, that book doesn't exist. I'm guessing that you can't even get clear and complete. As a comparison, I took a look at an Oracle 9i reference. The whole book is over 1200 pages – the reference section, the section that is comparable in style and content to SQL Pocket Guide, is over 350 pages. The syntax diagram for the SELECT statement is terrifying just on its own.

From this syntax diagram, I discovered that Oracle has a "flashback" feature, which under certain circumstances allows you to look at the database as it was at a time in the recent past: SELECT * from EMPLOYEES AS OF (some time in the past) The problem is that the chapter on flashback queries doesn't discuss this particular syntax – here, you're on your own. As you might expect, a 1200 page book isn't an ideal learning tool, but it's not a perfect reference either. On the other hand, SQL Pocket Guide doesn't cover flashback queries at all.

SQL Pocket Guide doesn't contain every single thing anyone will ever need to know about any of the five covered databases. Different people will find different gaps in what's included. The book doesn't include creating views, which I would have found useful. Also, I recently found myself with an SQL Server table so gnarly that I used two nested unpivot statements to unwind it, but unpivot, which is new in SQL Server 2005, isn't included in the book either. The book deserves its rating, however, because it's nearly perfect for its size.

In giving up completeness, Gennick hasn't just produced a book with fewer pages, he's produced a book that works either for learning or reference. Reading the book cover to cover is a rapid and effective way to get up to speed on a particular database. This is true if you are vaguely familiar with SQL and need specific details, or if you're intimately familiar with one database but moving to another. Unless or until you've committed the details of each SQL statement to memory, this book will be the best fifteen dollars you'll spend.

You can purchase SQL Pocket Guide, Second Edition from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
This discussion has been archived. No new comments can be posted.

SQL Pocket Guide, Second Edition

Comments Filter:
  • Update on the link (Score:2, Informative)

    by Anonymous Coward
    The article links to B & N, but it looks like Amazon has it cheaper [amazon.com]. Not that it makes much of a difference with something generally priced as low as an O'Reilly pocket guide, but it might help those penny pinchers.
  • Worth buying (Score:3, Interesting)

    by andrewman327 ( 635952 ) on Wednesday August 16, 2006 @03:41PM (#15921943) Homepage Journal
    My first love is Java, but I am required to work with databases for the project I am starting. I have taught myself how to code in it and have some experience but the proper use of some of the more obscure commands often evades me. Although the reviewer found navigating the book hard at times I think it will make a nice addition to my select next-to-computer library. Even reading the review I feel better informed about SQL!

    If you have never coded in SQL before, this book is not for you. Instead try this excellent website [sqlzoo.net].

  • SQLite? (Score:3, Informative)

    by Anonymous Coward on Wednesday August 16, 2006 @03:52PM (#15922025)
    http://sqlite.org/ [sqlite.org] is starting to gain acceptance as a decent database for standalone applications and medium-size static web applications. SQLite3 beat MySQL5 to the punch of having triggers and views. It also has transactions and is atomic. And it won an award from google *and* oreilly. Though a lot of the extraneous features are not present in sqlite (due to its size) but you can add your own functions (and aggregate functions). I don't think it would be much for OReilly to include sqlite in the handbook.
    • You left out the fact that SQLite is so good, it's becoming part of the stock python distribution as of 2.5.
      Get Hipp. Get SQLite!
    • There are probably many good uses for SQLite, but be aware of its published limitations.

      http://sqlite.org/omitted.html [sqlite.org]

    • Re: (Score:2, Insightful)

      by jgennick ( 59014 )
      I don't think it would be much for OReilly to include sqlite in the handbook.

      FWIW, I did run most of the example queries, those that aren't specific to Oracle, DB2, etc., against SQLite. And SQLite handles pretty much everything in the book that is not vendor-specific. I didn't specifically call out SQLite in the book, because to do so would force me to add sections on datatypes and conversion functions, and I was already over the top of my pagecount.

      BTW, I was the original editor behind Michael Owens' "The
  • by neonprimetime ( 528653 ) on Wednesday August 16, 2006 @03:59PM (#15922070)
    How many of you actually work somewhere where you need to know multiple SQL environments (MySQL, Postgresql, db2, oracle, sql server, etc.)? Cause if you don't need to know multiple, wouldn't it be nicer to have 1 book that concentrates simply on the one at hand? I'm not talking about using the book to learn new SQL, I'm just talking about using it as a reference at work? For most instances, wouldn't you just want a book that concentrates hard on 1, not a book that has broad statements about each?
    • by Anonymous Coward
      Here at my company we have Db/2, Access, SQL Server, & PL/SQL.
    • Pick up a 'UNIX' administration guide, and count the 'UNIXes' in there; Linux (Redhat, SUSE, Debian, Slackware...), FreeBSD, Solaris, HP-UX, AIX, Tru64, (not mentioning SCO), etc..

      If you're going to carry it in your pocket, why not have points of perspective?

      Like it or not, if you are supporting or developing for applications in an enterprise or corporate environment, it doesn't take more than two or three projects to span more than one RDMS - not to mention versions. Statements to Oracle 7 can have differ
    • by MankyD ( 567984 ) on Wednesday August 16, 2006 @04:10PM (#15922143) Homepage
      I own the first edition of the book and, first off, let me say I am very impressed by it. Note that it is entirely, from cover to cover, a reference book.

      90% of SQL syntax, between db's, is the same. Why get whole volumes when 90% of it would be redundant? When you finish one project using SQL Server, why by a whole new book that covers PostgreSQL?

      Also, it is not uncommon to work in non-homogenous database environmnets. Different projects and programs call for different database needs.
    • Well, when you are converting from one DBMS to another, it is nice to know the differences and idiosyncracies of each. Plus I'm sure there are some shops out there where they have multiple database servers, each using the latest flavor of the month. Also, there are plenty of good books out there that are vendor specific, so having a book that lets you transfer knowledge of one DBMS to another (say if you switch jobs) is nice to have as well.
    • Considering I use MySQL, PostgreSQL, and DB2 both for home and work projects, I'm getting a copy for myself. SQLite info would have been nice though as I'm planning some work with it too.
    • I have to use both Oracle and SQL Server most every day, depending on which database I am accessing.

      This book sounds incredibly useful.
    • > How many of you actually work somewhere where you need to know multiple SQL environments...

      I do. And I also want to know if I'm using a portable or a vendor specific statement.

      "The time to stop talking is when the other person nods his head affirmatively but says nothing."

      - Henry S. Haskins

    • I have MSSql, MySql, Oracle, and Sybase.
    • Anyone working in a large mature company will encounter many DBs. Presently I'm in a bank- I'm doing a lot of work in SQL Server& Teradata, I come from an Oracle background so good to have that in the mix. Also I've to read/QA code for both DB2 & MYSQL. I'd jump at a book like that bar the fact that it is missing Teradata. This is peculiar as: 1) Teradata is only used as a DW in mature environments 2) These environments will have lots of cross overs as above 3) Not being start ups/free/hobbies ed
    • I used to work for and used Oracle, SQL Server. Then on a side project I used Oracle, but switched that to MySQL later. So, yeah, people use more then one on a regular basis.
    • * raises hand *

      I actually work at such a place! I do enterprise level development for a major manufacturer and switch between MSSQL and DB2 on a regular basis. We also have Oracle based apps but I've managed to avoid them. So far. But when I finally get called on to do Oracle work it's nice to know my first edition copy of this book will continue to serve me well.

      fwiw, I also use MySQL at home. I have definitely gotten my $$$'s worth from it and recommend it highly.
    • by lewp ( 95638 )
      My last job used everything you mentioned, save SQL Server. That was actually used too, just outside of my particular department. Of course, the company was large enough that we had dedicated DBAs that specialized in one or two of the systems, but you still needed to know your way around in case you were on call and something broke at 4am.
    • Perhaps this is kind of true (Actually, I work at a company that I use multiple SQL types) but for the novice SQL user who is only using one for educational purposes the concept that "SQL is not SQL" maybe helpful in them appreciating the structure of various types of SQL.

      It's much like buying a "windows/linux/PC for dummies" book, while not all aspects apply completely to the flavor of windows/linux/PC you're going to be using the rounded knowledge would, IMHO, go a long way.

      And, not having read the book
    • I'm a Java developer, in the past 18 months I've worked on Postgres, MySQL, DB2, Oracle and MSSQL.
      All of my co-workers are in the same boat. Most of us have at least 10 years of experience working with various mature and popular (at the time) databases. This is the current list, or rather the survivors. The biggest pain about moving around to all these databases is how to x in y database. You try having to switch environments that many times and see if you remember the syntactic details of each dialect. It'
  • SQL Book (Score:4, Funny)

    by Anonymous Coward on Wednesday August 16, 2006 @04:09PM (#15922129)
    To open the book, you need to issue a GRANT USER command.

    To show the table of contents you need to SELECT * from CONTENTS order by CHAPTER;

    To go to a specific chapter, say chapter 4, SELECT * from CONTENTS where CHAPTER = 4 order by PAGENUMBERS;

    If you want to study one chapter, then skip to another chapter, you'll have to work with Unions and Joins to arrange for that.

    If you want a timestamp and a bookmark as to what you're reading and when, you'll have to deal with a plethora of date conversion commands.

    Thankfully it's a small tome, otherwise you may accidentally DROP BOOK and hurt someone.

    Does it have an entry for SELECT * from BOOK WHERE SQL Like "A Pig" order by OINK;
    • by mge ( 120046 )
      db2scp> db2 "select * from anonymous_coward where clue > 0"
      0 rows selected

  • books like this kinda drive me nuts, because you shouldn't need to refer to 4 different sections to get oracle vs db2 vs MSSQL, etc. "Versions" of SQL. The vast majority of the language syntax should be the same, and we should be sure to specify that. The summary infers that the differences are vast enough that you NEED different sections to understand the different flavors.
    • I don't know about the second edition, but I have the first and I use it - a lot! It's great and the small size makes it easy to carry around in my gear bag.

      The book isn't about the different database products as it is about SQL in general, so it's not really divided into sections by database (oracle vs db2, etc.). As you say, the majority of SQL is the same between various db's. The first edition documents SQL in general and only footnotes product differences when and where they exist. Most of its cont
  • by kimanaw ( 795600 ) on Wednesday August 16, 2006 @05:00PM (#15922589)
    I've skimmed the book and considered the purchase, but I've been hacking SQL for decades now, and can't really justify it. If only the author had provided an error code cross reference for all those DBMS's, I would pay much, much more than its cover price.

    Error codes remain the one area where SQL variants have vast differences - SQLSTATE support is still pretty hit and miss - and so, while syntax portability is getting better and better, application portability remains a challenge.

  • I own the book, and it's absurdly condensed. It's laid out well, with several topics listed under their own header and from there referenced back to an earlier section. (Example: Recursive querying is covered under "hierarchical queries" but both have a spot in the TOC).
    For a pocket guide, it's great, especially with the comparison across all of the major SQL flavors (don't get me started on the Linux Pocket Guide, which is tailored to Fedora). It even makes some notices between different versions of datab
    • Re: (Score:2, Informative)

      by jgennick ( 59014 )
      One 'gripe' is that the author changed the structure of his website since the book was published, so all of the book urls are broken.

      I truly, truly, am trying to get all those URLs back in working order. Some articles I've gotten back up. Others not. I always seem to be behind the eight-ball when it comes to getting work done though. Even tonight I'm working late on my day-job.

      Heh. Had I known I was going to get Slashdotted, I might have pulled a few all-nighters to get all my articles back up on my site :-
  • Nerdbooks (Score:3, Insightful)

    by z_gringo ( 452163 ) <z_gringo@@@hotmail...com> on Wednesday August 16, 2006 @07:38PM (#15923516)
    It is even cheaper than all 3 sites already mentioned at Nerdbooks.com [nerdbooks.com]

    I buy almost all my books from them. They have great prices and a great selection.

    • Re:Nerdbooks (Score:3, Informative)

      Looks like a good deal, but don't waste any time creating a customer account if you are out of the United states of America.

      They ship to the good ol USA only...
  • by Anonymous Coward
    that Amazon had editorial input into this book. The authors also wanted to include a bug list at time of publication, but including the MySQL bug list would have made the book so heavy it could not have been air freighted.
  • by hacker ( 14635 ) <hacker@gnu-designs.com> on Thursday August 17, 2006 @11:03AM (#15926791)
    If you're using a Palm device and you have Plucker [plkr.org] installed (grab one of the snapshots [plkr.org] to get the latest), you can get the freshly-built FULL MySQL [mysql.com] 4.1, 5.0 and 5.1 documentation here [nyud.net], and the PostgreSQL [postgresql.org] documentation for 8.1.4 here [nyud.net].

    Enjoy, and let me know if there's anything else we can do.

    (don't forget to check out the other things we've created for you over here [nyud.net])

"There is no distinctly American criminal class except Congress." -- Mark Twain