Re: sql formatter/beautifier

From: "Joris Dobbelsteen" <Joris(at)familiedobbelsteen(dot)nl>
To: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
Cc: "postgres general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: sql formatter/beautifier
Date: 2007-02-03 12:41:44
Message-ID: 73427AD314CC364C8DF0FFF9C4D693FF5543@nehemiah.joris2k.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)postgresql(dot)org
>[mailto:pgsql-general-owner(at)postgresql(dot)org] 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(at)postgresql(dot)org so
>that your
> message can get through to the mailing list cleanly
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Allison 2007-02-03 13:17:14 Re: PG Email Client
Previous Message Peter 2007-02-03 12:17:30 Re: Rule, update and aggregate functions