Re: insert into ... select ... and column order

Поиск
Список
Период
Сортировка
От Tino Wildenhain
Тема Re: insert into ... select ... and column order
Дата
Msg-id 478CA6D1.5080806@wildenhain.de
обсуждение исходный текст
Ответ на insert into ... select ... and column order  (Tore Halset <halset@pvv.ntnu.no>)
Список 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


В списке pgsql-general по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Segmentation fault with 8.3 FTS ISpell
Следующее
От: Oleg Bartunov
Дата:
Сообщение: Re: Segmentation fault with 8.3 FTS ISpell