Re: list manipulation at column level

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: list manipulation at column level
Дата
Msg-id 20050911232501.GA52427@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: list manipulation at column level  (Chris Travers <chris@travelamericas.com>)
Ответы Re: list manipulation at column level  (Matthew Peter <survivedsushi@yahoo.com>)
Список pgsql-general
On Sun, Sep 11, 2005 at 04:02:24PM -0700, Chris Travers wrote:
> Matthew Peter wrote:
> >Is it possible to append and delete (unknown location)
> >items in a list stored in a column? For instance,
> >
> >a column with 'some,values,in,a,list,12,34';
> >
> >Could I [ap|pre]pend and or delete items in this list
> >through pgsql?
> >
> prepend:
> 'value' || ',' || column
> append
> column || ',' ||'value'

Or use an array type and perform array operations.

http://www.postgresql.org/docs/8.0/interactive/arrays.html
http://www.postgresql.org/docs/8.0/interactive/functions-array.html

CREATE TABLE foo (a text[]);
INSERT INTO foo VALUES ('{some,values,in,a,list,12,34}');

SELECT array_prepend('foo', a) FROM foo;
              array_prepend
-----------------------------------------
 [0:7]={foo,some,values,in,a,list,12,34}
(1 row)

SELECT array_append(a, 'foo') FROM foo;
           array_append
-----------------------------------
 {some,values,in,a,list,12,34,foo}
(1 row)

SELECT array_cat(a[1:2], a[6:7]) FROM foo;
      array_cat
---------------------
 {some,values,12,34}
(1 row)

--
Michael Fuhr

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

Предыдущее
От: Chris Travers
Дата:
Сообщение: Re: list manipulation at column level
Следующее
От: Matthew Peter
Дата:
Сообщение: Re: list manipulation at column level