Search Postgresql Archives

Re: sql formatter/beautifier

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



PostGreSQL (7.4 and onward) has such a thing build-in, but its not
particulary good (simple case works, but once it gets complex it makes a
mess out of it).

For example the postgresql formatted version
$CREATE OR REPLACE VIEW "Subquery" AS 
$ SELECT t1.a, t2.b
$   FROM ( SELECT 1 AS a, 2 AS x) t1
$   JOIN ((( SELECT 1 AS b, 2 AS x
$UNION ALL 
$         SELECT 1 AS b, 2 AS x)
$UNION 
$         SELECT 1 AS b, 2 AS x)
$UNION ALL 
$         SELECT 1 AS b, 2 AS x) t2 ON t1.x = t2.x
$  WHERE (t1.a IN ( SELECT 1
$UNION 
$    SELECT 2));
(hopefully the mailer doesn't mess with the spacing)

I just found http://psti.equinoxbase.com/
There is a online demo and it works perfectly on this query:
$CREATE OR REPLACE VIEW "Subquery" AS 
$SELECT t1.a, t2.b
$FROM ( SELECT 1 AS a, 2 AS x) t1
$JOIN ((( SELECT 1 AS b, 2 AS x
$         UNION ALL 
$         SELECT 1 AS b, 2 AS x)
$       UNION 
$       SELECT 1 AS b, 2 AS x)
$      UNION ALL 
$      SELECT 1 AS b, 2 AS x) t2 ON t1.x = t2.x
$WHERE (t1.a IN ( SELECT 1
$                 UNION 
$                 SELECT 2));

Probably such a thing should be integrated into postgresql...

- Joris

>-----Original Message-----
>From: pgsql-general-owner@xxxxxxxxxxxxxx 
>[mailto:pgsql-general-owner@xxxxxxxxxxxxxx] On Behalf Of Merlin Moncure
>Sent: vrijdag 2 februari 2007 16:38
>To: postgres general
>Subject: [GENERAL] sql formatter/beautifier
>
>I am wondering if anybody can suggest a good sql formatting 
>tool.  I searched for the obvious things on google and can't 
>find a good solution. The requirements are:
>
>* linux version strongly preffered
>* pl/pgsql preffered, but not required
>* must be able to be run from script (bash, etc)
>* must be highly configurable
>
>free/open source preferred, but not required
>
>merlin
>
>---------------------------(end of 
>broadcast)---------------------------
>TIP 1: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so 
>that your
>       message can get through to the mailing list cleanly
>


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux