Try fsqlf
fsqlf is a command line or GUI program, open source, to format SQL. It supports having a formatting.conf file which allows you a lot of flexibility in how the final product looks.
Example 1:
☺ [wwalker@speedy:~]
$ echo "select f1, f2, fname, lName from tblName where f1 = true and fname is not null order by lName asc" | fsqlf
SELECT
f1
, f2
, fname
, lName
FROM tblName
WHERE f1=true
AND fname is not null
ORDER BY lName asc
Example 2:
☺ [wwalker@speedy:~]
$ vim formatting.conf # 2 character change
☺ [wwalker@speedy:~]
$ echo "select f1, f2, fname, lName from tblName where f1 = true and fname is not null order by lName asc" | fsqlf
SELECT
f1 ,
f2 ,
fname ,
lName
FROM tblName
WHERE f1=true
AND fname is not null
ORDER BY lName asc
Example 3:
☺ [wwalker@speedy:~]
$ vim formatting.conf # 1 character change
☺ [wwalker@speedy:~]
$ echo "select f1, f2, fname, lName from tblName where f1 = true and fname is not null order by lName asc" | fsqlf
SELECT
f1 , f2 , fname , lName
FROM tblName
WHERE f1=true
AND fname is not null
ORDER BY lName asc