Re: how to convert relational column to array?

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: how to convert relational column to array?
Дата
Msg-id 20051219165449.GA99764@winnie.fuhr.org
обсуждение исходный текст
Ответ на how to convert relational column to array?  (george young <gry@ll.mit.edu>)
Ответы Re: how to convert relational column to array?  (george young <gry@ll.mit.edu>)
Список pgsql-sql
On Mon, Dec 19, 2005 at 11:06:12AM -0500, george young wrote:
> create table new_tab(name text, id int, permits text[]);
> 
> -- I insert one row per name:
> insert into new_tab select distinct name,id,cast('{}' as text[]) from old_tab;
> 
> Now I want to fold all the 'permits' values into the new permits arrays.

In PostgreSQL 7.4 and later you can build an array from a select,
so I think the following update should work (it did for me when I
tested it):

UPDATE new_tab SET permits = array( SELECT permits FROM old_tab WHERE old_tab.name = new_tab.name AND old_tab.id =
new_tab.id
);

-- 
Michael Fuhr


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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Question on indexes
Следующее
От: george young
Дата:
Сообщение: Re: how to convert relational column to array?