Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for an embeddable SQL beautifier or reformatter [closed]

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.

like image 693
Brian Matthews Avatar asked Nov 23 '08 14:11

Brian Matthews


People also ask

What is SQL beautifier?

SQL Formatter helps to format SQL code data and it helps the developer easy to read the SQL. This tool helps uses to beautify large SELECT statements and make it easy to read. SQL formatting is a tedious task, which can be handled by an SQL formatter.

How do I get beautify code in SQL Developer?

How do you format your SQL code in SQL Developer? You can press CTRL+F7 (on Windows) to format the SQL code in your current Code Editor window to update the formatting of the code based on any format changes you have made.

How can I beautify SQL code in SSMS?

Format SQL Code in SSMS Query Window To use the SSMS add-in component we will have to close and then open SSMS after the install of the add-in. Then open a SSMS query window, highlight the code that needs to be formatted. Then select Format T-SQL Code from the SSMS Tools menu. Here is the code after the formatting.


1 Answers

UPDATE 2:

org.hibernate.jdbc.util.BasicFormatterImpl got moved in release 4.0. It is now located at: org.hibernate.engine.jdbc.internal.BasicFormatterImpl.

UPDATE 1:

Technology marches on. As noted by Alex, org.hibernate.pretty.Formatter no longer exists as of version 3.3.2.GA. The replacement is org.hibernate.jdbc.util.BasicFormatterImpl:

String formattedSQL = new BasicFormatterImpl().format(sql); 

ORIGINAL ANSWER:

If you're using Hibernate, they've got one built-in: org.hibernate.pretty.Formatter

String formattedSQL = new Formatter(sql).format(); 
like image 76
Robert J. Walker Avatar answered Sep 25 '22 21:09

Robert J. Walker