Looking for an embeddable SQL beautifier or reform

2019-01-21 13:45发布

I am looking for a Java open source beautifier or reformatter for SQL that I can use to clean up DDL statements that I am generating with openArchitectureWare.

Nothing in the answer to "Online Code Beautifier And Formatter" is of use to me and I have not been able to get Simple SQL Formatter to work for me.

8条回答
等我变得足够好
2楼-- · 2019-01-21 14:22

Perhaps jsqlparser will work for you.

Not as easy to find as you might think, as there are a fair few defunct projects out there. In fact i failed to find it so ended up doing my own thing (based on the h2 parser - you can contact me if all else fails). As a consequence i do not know if it has a beautifier, but writing one on top should be straight forward enough.

Its based on a grammar and JavaCC, so probably a better option than reinventing this wheel with antlr in any event. You may find if you need to support various dialects of sql in complex statements that any approach based on a grammar will fail you.

查看更多
走好不送
3楼-- · 2019-01-21 14:26

Would this work - SQL Formatter.

查看更多
登录 后发表回答