Re: Best way to use indexes for partial match at

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Jaime Casanova <systemguards(at)gmail(dot)com>
Cc: Andrus <eetasoft(at)online(dot)ee>, pgsql-general(at)postgresql(dot)org
Subject: Re: Best way to use indexes for partial match at
Date: 2005-11-09 22:32:03
Message-ID: 1131575523.3554.53.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 2005-11-09 at 16:23, Jaime Casanova wrote:
> On 11/9/05, Andrus <eetasoft(at)online(dot)ee> wrote:
> > >> CREATE TABLE foo ( bar CHAR(10) PRIMARY KEY);
> > >>
> > >> Cluster locale is non-C. Database encoding is UTF-8. Postgres vers is 8.1
> >
> > >Do this instead:
> >
> > >CREATE TABLE foo ( bar CHAR(10) NOT NULL );
> > >CREATE UNIQUE INDEX foo_bar ON foo(bar char_pattern_ops);
> >
> > Martijn,
> >
> > Thank you. I have CHAR columns and need a primary key also. So I tried the
> > code
> >
> > CREATE TABLE foo ( bar CHAR(10) NOT NULL );
> > CREATE UNIQUE INDEX foo_bar ON foo(bar bpchar_pattern_ops);
> > ALTER TABLE foo ADD PRIMARY KEY (bar);
> >
> > I found that adding primary key creates another index.
> >
> > How to create primary key without duplicate index on bar column ?
> >
> > Andrus.
> >
> >
>
> you can't.
> postgresql implements primary keys creating unique indexes and not
> null constraints on the pk columns.

But, of course, you CAN delete that other index now that it's redundant.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andreas 2005-11-10 00:23:16 Re: Schemas shown in ODBC
Previous Message Jaime Casanova 2005-11-09 22:23:26 Re: Best way to use indexes for partial match at beginning