From: | Tino Wildenhain <tino(at)wildenhain(dot)de> |
---|---|
To: | Tore Halset <halset(at)pvv(dot)ntnu(dot)no> |
Cc: | Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: insert into ... select ... and column order |
Date: | 2008-01-15 12:28:01 |
Message-ID: | 478CA6D1.5080806@wildenhain.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Tore Halset wrote:
> Hello.
>
> One of our users tried a "insert into ... select ..." that gave a
> strange error message. After digging into the issue, the problem seem to
> be that the order of the columns in the select statement must match the
> table definition. Here is a way to reproduce this case.
...
>
> Why does the column order matter when the subselect has all the correct
> column names?
When I noticed this long ago I just blamed it to SQL standards ;)
I do admit I never checked with the documentation.
And yes the names of the columns do not matter, just use the correct
order - either default or better:
INSERT INTO ... ( a,b,c ) SELECT a,b,c FROM ....
since new columns or reorder would not disturb your insert.
Regards
Tino
From | Date | Subject | |
---|---|---|---|
Next Message | Oleg Bartunov | 2008-01-15 12:46:20 | Re: Segmentation fault with 8.3 FTS ISpell |
Previous Message | T.J. Adami | 2008-01-15 12:26:37 | Re: COUNT() with ORDER BY |