Editorials

It Isn’t ANSI Standard

Lately I’ve been reading a lot of blogs and online content about many different SQL topics, reaching back into how we used to do things in the old days. One phrase I see consistently is that a certain syntax, “does not follow the ANSI standard.” Sometimes they writer is incorrect.

One thing that is true about the SQL syntax is that it is a dynamic, slowly moving specification, being modified to enhance capabilities, and standardize ways that things are done. An engine that is ANSI Compliant for the SQL Syntax is more likely to be used because the code is more transportable to other data engines.

So, lest we forget, the ANSI SQL specification is always maturing. Since SQL was picked up to be a managed specification there have been a number of versions with specific features added in each time. WikiPedia has a nice list of the different major releases. Not all vendors meet all of the specifications for any release. Moreover, they are sometimes ahead of the specification, releasing features still being defined in the specification.

The point is that, if there are differences in syntax for SQL to do the same thing, it doesn’t mean that either one of the different implementations must not be ANSI compliant. They may not be compliant. But, since the standards have changed over time, it is possible to have two different queries using different syntax both follow different ANSI standards.

Aim to use the later specification in your code. But, don’t assume that someone doing something else was using a bazzar implementation from some rogue database engine.

Cheers,

Ben

Facebooktwittergoogle_plusredditpinterestlinkedinmail
  • Martin van Gils

    The nice thing about standards is there are so many to choose from 🙂

  • Greg Hamilton

    I think performance, fit for purpose, cost and a history of maintaining backward compatibility are MUCH bigger considerations than strict standards compliance.

  • Chris Fair

    I used to be on the side that was pro-coding to the ANSI standards. Lately though, I’ve come to realize that it really depends on your work environment. If you’re a vendor that wants to make your product available to as many platforms as possible, then yes, I think you should code to the ANSI standard as much as possible. However, if you’re an internal developer working for some company that is vendor specific (e.g. an all Microsoft or all Oracle shop), then why wouldn’t you code to the platform? That way you are able to take advantage of built-in functions that were designed specifically for your environment, making it much easier on the developers and, quite possible, making your code faster and more efficient. As with most database topics, the correct path is “it depends”.