Skip site navigation (1) Skip section navigation (2)

Re: Create index on array element?

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Dave Bodenstab <dave_bodenstab(at)sbcglobal(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Create index on array element?
Date: 2006-11-30 23:26:21
Message-ID: 1164929181.7773.142.camel@dogma.v10.wvs (view raw or flat)
Thread:
Lists: 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


In response to

Responses

pgsql-general by date

Next:From: wheelDate: 2006-12-01 00:15:40
Subject: Restore database from files (not dump files)?
Previous:From: Jim NasbyDate: 2006-11-30 22:05:45
Subject: Re: Blob fields and backups

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group