word on the street is that Perl is defined not by a spec but by whatever the current interpreter version happens to accept. Now, let's consider an SQL dialect like TSQL. Is there a published spec of it that would allow making a validator equivalent to the one inside SQL Server? Are there such validators already in existence as open source? And the same question for Oracle.

Ok, so for MySQL I am guessing that validator could be extracted directly from the MySQL codebase. Nevertheless, do they in fact publish the spec itself in case I wanted to make my own validator?

1

There are 1 best solutions below

0
On

You seem to have an idea of what to do for MySQL. I can't really say much about Oracle apart from that it mostly implements ANSI SQL and the PL/SQL procedural language extensions to SQL can mostly be found here for Oracle 9i.

For SQL Server:

Microsoft Books On Line (BOL) is the official reference spec. There are different pages for different versions of SQL Server, however. There are a few projects relating to this. http://www.sqlparser.com/ - This has .NET, Java, COM and VCL versions for Oracle, DB2, Mysql and SQL Server / Sybase (T-SQL). Quite reasonably priced too.

http://www.codeproject.com/Articles/1136/SharpHSQL-An-SQL-engine-written-in-C (c#)

http://antlr.org/ - This looks like a good bet.

I often use this site for formatting of SQL but it also does some validation although it's fairly crude: http://www.dpriver.com/pp/sqlformat.htm

This is a similar site: http://www.tsqltidy.com/

I would suggest that writing a validator for SQL even in just one of its variations is a massive undertaking. You could look at the various ISO/IEC standards for ANSI SQL. ANSI SQL-92 is very widely implemented, but there is a SQL:2008 standard as well. You'd have to pay for the documentation for those standards though and they aren't cheap.

Good luck.