Member Book Review

Mastering Oracle SQL

Reviewed by John Rehg
Suncoast Oracle Users Group

Mastering Oracle SQL
Second Edition: June 2004
Sanjay Mishra and Alan Beaulieu
ISBN 10: 0-596-00632-2
ISBN 13: 9780596006327
June 2004
$39.95 USD

I read recently that developers are really artists. One tool for the artist-developer toolbox should be Mastering Oracle SQL, by Sanjay Mishra and Alan Beaulieu. In its second edition it covers Oracle SQL from the basics to analytics, to regular expressions and model queries. Think primary colors on the artist's palette. Think subtle hues for the master painter. The style of writing and clarity of examples makes this a great introduction to the language for the beginner. The more advanced topics of analytics and regular expressions, grouping sets, objects and collections should satisfy the advanced programmer.

I liked that all the examples are taken from a small database that the authors lay out in the beginning. You can download the code to create and populate this database from here.

I was thinking I could skim over the first few chapters since I have been using Oracle SQL for over eight years, but I was intrigued by the syntax they used in the very beginning that I had never seen before. I had to skip to chapter 3 to find out more about JOIN. Introduced in 9i for standards compatibility, my first inclination was to dismiss it as useless. I skipped to the very back of the book to find the advantages of using the JOIN syntax. I still wasn't convinced. We have a database on 9i and another on 10g, so I wrote a small query using the syntax, to see what it would look like. For some reason, writing a query out looks different to me than just reading it in a book. I could see the ease of maintainability and readability by separating the join conditions from the filter conditions. This would be very beneficial in large queries. The other major benefit is that JOIN gives you the ability to do full outer joins (table to table), which isn't possible in a single line using the (+) syntax from earlier versions. The multi-table insert, introduced in 9i, is another feature that looks really useful, and shows up in the beginning of the book.

I've used DECODE extensively in the past, some might say to the point of absurdity. I've written queries with nested decodes up to 7 levels deep, which I couldn't in good conscience give to anyone else to maintain. But I learned that, already available in 8i, you can use a select statement inside a DECODE function. Then the authors compare it to and make the case for the advantages of the case statement.

The authors state up front that they will not delve into sql tuning as a separate topic. They consider tuning a big enough topic to warrant its own book, as has already been done by others. I found it a little distracting to be continually reminded of this throughout the book. They also included a short chapter on PL/SQL, which, although well written, belongs in a book on PL/SQL. I think it would have been helpful to use margin notation on those features new to 10g. You couldn't just skim it to find out when a feature was introduced. If you are already on 10g, this won't be a problem.

About the first third of the book covers the basics, then it goes into more advanced topics, such as hierarchical queries, partitioning, objects, collections and analytics before ending with several 10g specific areas: regular expressions and model queries. They also have a chapter on best practices. I found their suggestions to be very helpful, and also thought it was beneficial to see how Oracle would internally respond to different query structures. Understanding that would improve a programmer's efficiency in writing high quality code.

Overall I thought it was a good book. It's not a real thick book, at under 400 pages, but it gives a good starting point on the capabilities of Oracle's implementation of SQL. As a developer, it's easy to stay in a comfort zone when coding. This book could help you break out of that and into new and more creative ways to solve problems using SQL.