是否有针对主要 SQL 方言(TSQL、Oracle、MySQL)的开源验证解析器?或者至少是这些方言的精确规范?
坊间流传的说法是,Perl 不是由规范定义的,而是由当前解释器版本碰巧接受的任何内容定义的。现在,让我们考虑像 TSQL 这样的 SQL 方言。是否有一个已发布的规范允许制作与 SQL Server 内部的验证器等效的验证器?是否已经存在这样的开源验证器? Oracle 也有同样的问题。
好的,对于 MySQL,我猜测验证器可以直接从 MySQL 代码库中提取。然而,如果我想制作自己的验证器,他们实际上会发布规范本身吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎知道要为 MySQL 做什么。关于 Oracle,我真的不能说太多,除了它主要实现 ANSI SQL,并且 SQL 的 PL/SQL 过程语言扩展大多可以在 此处(适用于 Oracle 9i)。
对于 SQL Server:
Microsoft 在线图书 (BOL) 是官方参考规格。但是,不同版本的 SQL Server 有不同的页面。
有几个与此相关的项目。
http://www.sqlparser.com/ - 具有适用于 Oracle 的 .NET、Java、COM 和 VCL 版本、DB2、Mysql 和 SQL Server/Sybase (T-SQL)。价格也相当合理。
http://www.codeproject.com/Articles /1136/SharpHSQL-An-SQL-engine-writing-in-C (c#)
http://antlr.org / - 这看起来是一个不错的选择。
我经常使用这个站点来格式化 SQL,但它也做了一些验证,尽管它相当粗糙:
http://www.dpriver.com/pp/sqlformat.htm
这是一个类似的地点:
http://www.tsqltidy.com/
我建议为 SQL 编写一个验证器,即使只是其中之一它的变化是一项艰巨的任务。您可以查看 ANSI SQL 的各种 ISO/IEC 标准。 ANSI SQL-92 得到了广泛的实施,但也有一个 SQL:2008 标准。
不过,您必须为这些标准的文档付费,而且它们并不便宜。
祝你好运。
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.