SQL Query Formatter

This extension will beautify or prettify your SQL query. In other words, it will take an ugly query like this:

SELECT * FROM (SELECT i.field1, i.field2, d.field3, p.field4, pt.field5, i.field6, p.field7, d.field8, d.field9, d.field10, d.field11, i.field12, i.field13, i.field14, i.field15, i.field16, v.field17 FROM table1 i INNER JOIN table2 q ON q.field1 = i.field1 INNER JOIN table2 p ON p.field1 = q.field1 LEFT OUTER JOIN table3 d ON d.field1 = i.field1 LEFT OUTER JOIN table4 p ON p.field1 = i.field1 LEFT OUTER JOIN table5 ist ON ist.field1 = i.field1 LEFT OUTER JOIN table6 pt ON pt.field4 = p.field4 LEFT OUTER JOIN table7 iqh ON i.field14 = iqh.field14 LEFT OUTER JOIN table8 v ON d.field1 = v.field1 WHERE  i.field5 = ? ORDER BY p.field6) WHERE ROWNUM <= 5000

and it will make it easier to read by formatting it into this:

SELECT * from
(SELECT i.field1, i.field2, d.field3, p.field4, pt.field5, i.field6, p.field7, d.field8, d.field9, d.field10, d.field11, i.field12, i.field13, i.field14, i.field15, i.field16, v.field17 FROM table1 i
INNER JOIN table2 q ON q.field1 = i.field1
INNER JOIN table2b p ON p.field1 = q.field1
LEFT OUTER JOIN table3 d ON d.field1 = i.field1
LEFT OUTER JOIN table4 p ON p.field1 = i.field1
LEFT OUTER JOIN table5 ist ON ist.field1 = i.field1
LEFT OUTER JOIN table6 pt ON pt.field4 = p.field4
LEFT OUTER JOIN table7 iqh ON i.field14 = iqh.field14
LEFT OUTER JOIN table8 v ON d.field1 = v.field1
where i.field5 = ? ORDER BY p.field6)
where ROWNUM <= 5000

This extension will add line breaks for every subquery and every join, which will make the query much easier to read.

How it works:

1. Copy a SQL query to the clipboard.
2. Press the Keybreeze hotkey and type a keyword to run the SQL Query Formatter.exe file.
3. Paste the formatted query in your text editor or other application.

Download instructions:

Download the attached zip file and extract the contents. Right-click the SQL Query Formatter.exe file and click Add keyword to Keybreeze. Then follow the instructions in the example above.



Attachments: SQL Query Formatter.zip  



No comments yet.