Andreas Kretschmer <andr...@a-kretschmer.de> (Mi 23 Jul 2014 23:50:53 CEST):
> 
> 
> Mir scheint, Du suchst sowas wie:
> 
> test=# create type colors as enum ('red','green', 'blue');
> CREATE TYPE
> test=*# create table foobar (id int, color colors[]);
> CREATE TABLE
> test=*# insert into foobar values (1, array['red'::colors, 'blue'::colors]);
> INSERT 0 1
> test=*# select * from foobar;
>  id |   color
> ----+------------
>   1 | {red,blue}
> (1 row)
> test=*# select id, array_to_string(color,',') as color from foobar;
>  id |  color
> ----+----------
>   1 | red,blue
> (1 row)
> 
> 
> 
> Also, erst einmal den Typ als ENUM und davon dann ein ARRAY.


Weil das so etwas schöner aussähe:

    SELECT name FROM items WHERE colors CONTAINS 'red';

Wie in der anderen Antwort beschrieben, wird es wohl tatsächlich die
normalisierte Darstellung werden, und keine Arrays.

Danke für die schnelle Hilfe.
-- 
Heiko

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Lug-dd maillist  -  Lug-dd@mailman.schlittermann.de
https://ssl.schlittermann.de/mailman/listinfo/lug-dd

Antwort per Email an