Re: default index created for primary key - Mailing list pgsql-general

From Sander Steffann
Subject Re: default index created for primary key
Date
Msg-id 000601c4e85d$04e11940$64c8a8c0@balefirehome
Whole thread Raw
In response to Re: default index created for primary key  ("vinita bansal" <sagivini@hotmail.com>)
List 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.



pgsql-general by date:

Previous
From: "Frank D. Engel, Jr."
Date:
Subject: Re: default index created for primary key
Next
From: John Cunningham
Date:
Subject: Re: postgresql.conf