MySQL 是否有任何 SQL 验证器可以针对多个数据库服务器检查语法?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7753081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Are there any SQL Validators that can check syntax against multiple database servers?
提问by Tahir Akhtar
Are there any SQL Validators that can check syntax against multiple database servers?
是否有任何 SQL 验证器可以针对多个数据库服务器检查语法?
For example, I might want to check whether a particular query will work against Oracle, MySQL and SQL Server.
例如,我可能想检查特定查询是否适用于 Oracle、MySQL 和 SQL Server。
I am more concerned about the SQL syntax than the actual schema being queried, so a tool that can catch major syntax errors, like detecting that the limit
clause is not supported in SQL Server and Oracle would be good enough.
我更关心 SQL 语法而不是被查询的实际模式,所以一个可以捕获主要语法错误的工具,比如检测limit
SQL Server 和 Oracle 不支持该子句就足够了。
EDIT:
编辑:
Several answers have suggested checking syntax for a particular DBMS or for ANSI Standard.
有几个答案建议检查特定 DBMS 或 ANSI 标准的语法。
What I am looking for a possibility of targeting a sort of union of features between two or more databases (say SQL Server and Oracle). I would like to be able to use any SQL feature that is supported by all of the DBMS I am targeting in a particular application.
我正在寻找一种针对两个或多个数据库(例如 SQL Server 和 Oracle)之间的某种功能联合的可能性。我希望能够使用我在特定应用程序中定位的所有 DBMS 支持的任何 SQL 功能。
I am not sure if it is worthwhile. I think it depends upon the number of non-ANSI features shared by several databases. If there are very few, then perhaps it will be better to target the ANSI standard.
我不确定这是否值得。我认为这取决于多个数据库共享的非 ANSI 功能的数量。如果数量很少,那么以 ANSI 标准为目标也许会更好。
回答by Kevin Burton
I'm not aware of any that are that specific, these will check that the statements are valid ansi 92/99/2003...
我不知道任何特定的,这些将检查语句是否有效 ansi 92/99/2003 ...
http://developer.mimer.com/validator/index.htm
http://developer.mimer.com/validator/index.htm
That will get you 99% of the way there (especially if are only doing CRUD operations)
这将使您完成 99% 的工作(尤其是在仅执行 CRUD 操作的情况下)
maybe if you know which reserved words are used by which database you could roll your own simple checker.. see : How to find if a column name is a reserved keyword across various databases
也许如果您知道哪个数据库使用了哪些保留字,您可以推出自己的简单检查器..请参阅:如何查找列名是否是各种数据库中的保留关键字
(as already mentioned) If your goal is to create a database agnostic system think about using a third party tool e.g: entityspaces
(如前所述)如果您的目标是创建一个与数据库无关的系统,请考虑使用第三方工具,例如:entityspaces
回答by Bogdan Sahlean
From SQL Server point of view, instead of checking sql syntax against multiple database server you could check syntax "for compliance with the FIPS 127-2 standard. This is based on the ISO standard.".
从 SQL Server 的角度来看,您可以检查语法“是否符合 FIPS 127-2 标准。这是基于 ISO 标准的”,而不是针对多个数据库服务器检查 sql 语法。.
Example:
例子:
SET FIPS_FLAGGER 'INTERMEDIATE'
回答by Devart
For the MySQL: try automatic SQL syntax checkfeature in dbForge Studio for MySQL.
对于 MySQL:在dbForge Studio for MySQL 中尝试自动 SQL 语法检查功能。
For the Oracle: PL/SQL Editor in dbForge Studio for Oracle
对于 Oracle:dbForge Studio for Oracle 中的PL/SQL 编辑器
回答by Girvan
This is an online mysql syntax checker, but this is mysql only http://www.piliapp.com/mysql-syntax-check/
这是一个在线 mysql 语法检查器,但这只是 mysql http://www.piliapp.com/mysql-syntax-check/