Re: default index created for primary key

From: "Sander Steffann" <steffann(at)nederland(dot)net>
To: "vinita bansal" <sagivini(at)hotmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: default index created for primary key
Date: 2004-12-22 19:30:40
Message-ID: 000601c4e85d$04e11940$64c8a8c0@balefirehome
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

> I am actually migrating indexes from oracle database to postgres. I wanted
> to turn it off so that index on the same columns is not created again
> (index created for primary key of a table). I'll probably need to check in
> that case and not create the index if it is on the primary key of the
> table since that will be created by default.

That is the most simple sollution I think.

> I am still not clear on why postgres has this restriction?
> By uniqueness, you mean to say that if later anyone wants to add a primary
> key constraint on a table which already has a primary key defined,
> postgres will use this index to determine that there is already a primary
> key defined and would not allow to add this constraint since a table
> cannot have two primary keys??

No, PostgreSQL uses the index to check that the same value can not occur
twice in the primary key field. A pretty important part of primary keys :-)

Sander.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mark 2004-12-22 19:31:59 loading only few rows from huge table
Previous Message Rick Morris 2004-12-22 19:20:16 Re: nice work on the new site