Re: Create index on array element? - Mailing list pgsql-general

From Jeff Davis
Subject Re: Create index on array element?
Date
Msg-id 1164929181.7773.142.camel@dogma.v10.wvs
Whole thread Raw
In response to Create index on array element?  (Dave Bodenstab <dave_bodenstab@sbcglobal.net>)
Responses Re: Create index on array element?  (Dave Bodenstab <dave_bodenstab@sbcglobal.net>)
List pgsql-general
On Wed, 2006-11-29 at 14:39 -0600, Dave Bodenstab wrote:
> I guess one cannot create an index on an element of an array?
>
> test=> create table test ( ordinal int[] );
> CREATE TABLE
> test=> create unique index x1 on test ( ordinal[1] );
> ERROR:  syntax error at or near ")" at character 45
> LINE 1: create unique index x1 on test ( ordinal[1] );
>                                                      ^

You need more parenthesis.

test=> create unique index x1 on test ( ( ordinal[1] ) );

The reason is because "ordinal[1]" is an expression, similar to "ordinal
[1] + 5" which would also need parenthesis.

Hope this helps,
    Jeff Davis


pgsql-general by date:

Previous
From: John McCawley
Date:
Subject: Re: Separation of clients' data within a database
Next
From: adurrant@cogeco.ca
Date:
Subject: initdb problem on Windows XP Home