Ian Morgan <imorgan@webcon.net> writes:
> The SQL for CREATE VIEW as output by pg_dump generates an error, because the
> appropriate nesting of SELECTs with parentheses is missing:
Hmm. You shouldn't *need* parentheses in most cases ...
> CREATE VIEW "agents" as (
> (
> SELECT DISTINCT
> employees.contact_id
> FROM
> employees
> ORDER BY
> employees.contact_id
> )
> UNION
> (
> SELECT DISTINCT
> contractors.contact_id
> FROM
> contractors
> ORDER BY
> contractors.contact_id
> )
> );
although I suppose this is a counterexample. Would it help any to point
out that ORDER BY inside an arm of a UNION is a complete waste of
cycles? That's probably why it didn't occur to anyone to test this.
BTW, the SELECT DISTINCTs are also a waste of cycles, since UNION will
do that anyway.
regards, tom lane