Performance Zone is brought to you in partnership with:

I am the founder and CEO of Data Geekery GmbH, located in Zurich, Switzerland. With our company, we have been selling database products and services around Java and SQL since 2013. Ever since my Master's studies at EPFL in 2006, I have been fascinated by the interaction of Java and SQL. Most of this experience I have obtained in the Swiss E-Banking field through various variants (JDBC, Hibernate, mostly with Oracle). I am happy to share this knowledge at various conferences, JUGs, in-house presentations and on our blog. Lukas is a DZone MVB and is not an employee of DZone and has posted 224 posts at DZone. You can read more from them at their website. View Full User Profile

The Great SQL Implementation Comparison Page

12.30.2013
| 5998 views |
  • submit to reddit

Fortunately, we have SQL standards. Or do we? It’s a well-known secret (or cynical joke) that the SQL standard is yet another SQL dialect among peers.

Standards by xkcd

Standards by xkcd

On this blog, we have pointed out so many differences between SQL dialects, it is hard to believe that anyone would even consider writing SQL strings rather than using jOOQ or Hibernate if they ever risk migrating their application to another database. Just consider these examples:

From the perspective of the jOOQ implementation, we know how tough it can be to abstract vendor-specific SQL away. Here’s an example piece of code that you don’t want to have in your application, dealing with the NVL() function:

switch (configuration.dialect().family()) {
  case ACCESS:
    return field("{iif}({0} is null, {1}, {0})");
 
  case DB2:
  case INGRES:
  case ORACLE:
  case H2:
  case HSQLDB:
    return field("{nvl}({0}, {1})", ..);
 
  case DERBY:
  case POSTGRES:
    return field("{coalesce}({0}, {1})", ..);
 
  case MARIADB:
  case MYSQL:
  case SQLITE:
    return field("{ifnull}({0}, {1})", ..);
 
  // By default, resort to the CASE expression
  default:
    return DSL.decode()
              .when(arg1.isNotNull(), arg1)
              .otherwise(arg2);
}

Now, trust us. The above is one of the easier cases. Consider the standardisation of the LIMIT .. OFFSET clause, for instance.

For an even more frightening overview, we recommend you visit Troels Arvin’s Comparison of Different SQL Implementations. Be warned, though!

Published at DZone with permission of Lukas Eder, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)