Re: Unique primary index?

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: PFC <lists(at)boutiquenumerique(dot)com>
Cc: orange_crush_068(at)hotmail(dot)com, pgsql-sql(at)postgresql(dot)org
Subject: Re: Unique primary index?
Date: 2005-06-28 17:47:22
Message-ID: 1119980842.8208.111.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, 2005-06-28 at 12:01, PFC wrote:

> >
> > What are the major differences between Unique, primary index & just
> > plain index?
> >
> > When creating tables I nominate one of these, but not sure what the
> > difference is?

> index is... an index !
>
> UNIQUE is an index which won't allow duplicate values (except for NULLS)
>
> PRIMARY KEY is exactly like UNIQUE NOT NULL, with the bonus that the
> database knows this column is the primary key so you can use stuff like
> NATURAL JOIN without telling which column you want to use.

No. natural join joins on columns with the same name. However,
primary keys ARE automatically referred to by fk'd columns.

Personally, I think that a natural join should use the primary/fk
relationship as well, but I guess that's not what the spec says.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Martín Marqués 2005-06-28 18:22:25 Re: ENUM like data type
Previous Message PFC 2005-06-28 17:01:07 Re: Unique primary index?