Online SQL syntax checker conforming to multiple databases

MysqlSql ServerOraclePostgresql

Mysql Problem Overview


Is there any site available online for verifying the syntax which conforms to multiple databases?

For example: If I have a SQL statement with a 'usage' keyword, then the site should throw me an error saying that 'usage' keyword is reserved in MYSQL?

Mysql Solutions


Solution 1 - Mysql

You could try a formatter like this

They will always be limited because they don't (and can't) know what user defined functions you may have defined in your database (or which built-in functions you have or don't have access to).

You could also look at ANTLR (but that would be an offline solution)

Solution 2 - Mysql

Solution 3 - Mysql

I haven't ever seen such a thing, but there is this dev tool that includes a syntax checker for oracle, mysql, db2, and sql server... http://www.sqlparser.com/index.php

However this seems to be just the library. You'd need to build an app to leverage the parser to do what you want. And the Enterprise edition that includes all of the databases would cost you $450... ouch!

EDIT: And, after saying that - it looks like someone might already have done what you want using that library: http://www.wangz.net/cgi-bin/pp/gsqlparser/sqlpp/sqlformat.tpl

The online tool doesn't automatically check against each DB though, you need to run each manually. Nor can I say how good it is at checking the syntax. That you'd need to investigate yourself.

Solution 4 - Mysql

Only know about this. Not sure how well does it against MySQL http://developer.mimer.se/validator/

Solution 5 - Mysql

I don't know of any such, and my experience is that it doesn't currently exist. Most are side by side comparisons of two databases. That information requires experts in all the databases encountered, which isn't common. Versions depend too, to know what is supported.

ANSI functions are making strides to ensure syntax is supported across databases, but it's dependent on vendors implementing the spec. And to date, they aren't implementing the entire ANSI spec at a time.

But you can crowd source on sites like this one by asking specific questions and including the databases involved and the versions used.

Solution 6 - Mysql

I am willing to bet some of my reputation that there is no such thing.

Partially because if you are worried about cross-platform SQL compatibility, your best bet in turn is to abstract your database code with some API or ORM tool that handles these things for you, and is well supported, so will deal with newer database versions as they come out.

Exact kind of API available to you will be dependent on your programming language/platform. For example, PHP has Pear:DB and others, I personally have found quite nice Python's ORM features implemented in Django framework. I presume there should be some of these things available on other platforms as well.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPhaniView Question on Stackoverflow
Solution 1 - MysqlGary MyersView Answer on Stackoverflow
Solution 2 - MysqlInfotekkaView Answer on Stackoverflow
Solution 3 - MysqlMichael BroughtonView Answer on Stackoverflow
Solution 4 - MysqlRemoteSojournerView Answer on Stackoverflow
Solution 5 - MysqlOMG PoniesView Answer on Stackoverflow
Solution 6 - MysqlGnudiffView Answer on Stackoverflow