Re: alter table add column - specify where the column will go?

Поиск
Список
Период
Сортировка
От Florian Weimer
Тема Re: alter table add column - specify where the column will go?
Дата
Msg-id 82tyj7hsa8.fsf@mid.bfk.de
обсуждение исходный текст
Ответ на Re: alter table add column - specify where the column will go?  (Grzegorz Jaśkiewicz <gryzman@gmail.com>)
Ответы Re: alter table add column - specify where the column will go?  (Fredric Fredricson <Fredric.Fredricson@bonetmail.com>)
Список pgsql-general
* Grzegorz Jaśkiewicz:

> 2010/11/24 Florian Weimer <fweimer@bfk.de>:
>> * Grzegorz Jaśkiewicz:
>>
>>> just never use SELECT *, but always call columns by names. You'll
>>> avoid having to depend on the order of columns, which is never
>>> guaranteed, even if the table on disk is one order, the return columns
>>> could be in some other.
>>
>> This can't be true because several SQL features rely on deterministic
>> column order.  Here's an example:
>>
>> SELECT 1 AS a, 2 AS b UNION SELECT 3 AS b, 4 AS a;
>>
>>  a | b
>> ---+---
>>  1 | 2
>>  3 | 4
>> (2 rows)

> Yes, most DBs do a good job to keep it consistent, but they don't have
> to. So unless you specify column names explicitly (like you did in the
> example above), there's no guarantees.

If the database looked at the column names, the result would be
(1, 2), (4, 3), not (1, 2), (3, 4).

--
Florian Weimer                <fweimer@bfk.de>
BFK edv-consulting GmbH       http://www.bfk.de/
Kriegsstraße 100              tel: +49-721-96201-1
D-76133 Karlsruhe             fax: +49-721-96201-99

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

Предыдущее
От: Grzegorz Jaśkiewicz
Дата:
Сообщение: Re: alter table add column - specify where the column will go?
Следующее
От: Dave Page
Дата:
Сообщение: Just 2 days left to register for PGDay.EU 2010