![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a table defined like this: scott=> \d t Table "public.t" Column | Type | Modifiers --------+----------------------+----------- col1 | character varying(3) | col2 | integer[] | |
#3
| |||
| |||
|
|
I have a table defined like this: scott=> \d t Table "public.t" Column | Type | Modifiers --------+----------------------+----------- col1 | character varying(3) | col2 | integer[] | Indexes: "ind_t_proj" btree (proj_elem_1(col2)) I would like to create an index on col2[1] but it's syntactically supported. I found a way to circumvent the limitation by doing the following: [...] Is there anything else, more elegant than creating a specialized function? |
#4
| |||
| |||
|
|
Mladen Gogala wrote: I have a table defined like this: scott=> \d t Table "public.t" Column | Type | Modifiers --------+----------------------+----------- col1 | character varying(3) | col2 | integer[] | Indexes: "ind_t_proj" btree (proj_elem_1(col2)) I would like to create an index on col2[1] but it's syntactically supported. I found a way to circumvent the limitation by doing the following: [...] Is there anything else, more elegant than creating a specialized function? It *is* syntactically supported. That was a Freudian lapse. CREATE INDEX ind_t_proj ON t ((col2[1])); Look at the syntax diagram for CREATE INDEX, there are extra parentheses around the "expression". The documentation says: The key field(s) for the index are specified as column names, or alternatively as expressions written in parentheses. I realize that this can easily be misinterpreted, but note the lack of comma after "expressions". Yours, Laurenz Albe |
![]() |
| Thread Tools | |
| Display Modes | |
| |