Foreword

In the 30 years since the database language SQL was initially adopted as an international standard, the SQL language has been implemented in a multitude of database products. Today, SQL is everywhere. It is in high-performance transaction-processing systems, in smartphone applications, and behind Web interfaces. There is even a whole category of databases called NoSQL whose common feature is (or was) that they don’t use SQL. As the NoSQL databases have added SQL interfaces, “No” is now interpreted as “Not Only” SQL.

Because of SQL’s prevalence, you are likely to encounter SQL in multiple products and environments. One of the (perhaps valid) criticisms of SQL is that while it is similar across products, there are subtle differences. These differences result from different interpretations of the standard, different development styles, or different underlying architectures. To understand these differences, it is helpful to have examples that compare and contrast the subtle differences in SQL dialects. Effective SQL provides a Rosetta Stone for SQL queries, showing how queries can be written in different dialects and explaining the differences.

I often claim that the best way to learn something is by making mistakes. The corollary to this claim is that the people who know the most have made the most mistakes and have learned from others’ mistakes. This book includes examples of incomplete and incorrect SQL queries with explanations of why they are incomplete and incorrect. This allows you to learn from mistakes others have made.

SQL is a powerful and complex database language. As a database consultant and a participant in both the U.S. and international SQL Standards committees, I’ve seen a lot of queries that did not take advantage of SQL’s capabilities. Application developers who fully learn SQL’s power and complexities can take full advantage of SQL’s capabilities not only to build applications that perform well, but also to build those applications efficiently. The 61 specific examples in Effective SQL assist in this learning.

—Keith W. Hare
Senior Consultant, JCC Consulting, Inc.; Vice Chair, INCITS DM32.2—the U.S. SQL Standards Committee;
Convenor, ISO/IEC JTC1 SC32 WG3—the International SQL Standards Committee