Re: How to create primary key

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Samantha Atkins <sjatkins(at)mac(dot)com>
Cc: rod(at)iol(dot)ie, Reg Me Please <regmeplease(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: How to create primary key
Date: 2007-11-06 09:57:00
Message-ID: 20071106095700.GC32607@svr2.hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Nov 06, 2007 at 01:38:31AM -0800, Samantha Atkins wrote:
>
> On Nov 6, 2007, at 1:15 AM, Raymond O'Donnell wrote:
>
> >On 06/11/2007 08:54, Reg Me Please wrote:
> >
> >>What'd be the syntax to create a primary key on an already build
> >>table?
> >
> >ALTER TABLE test ADD CONSTRAINT test_pk PRIMARY KEY (f1);
> >
>
> So, ALTER TABLE test ADD PRMARY KEY(f1 [, ... ] )
> isn't enough? It appears in the examples. What more does the
> explicit test_pk do that wouldn't happen anyway?

It's not needed. It gives a name to the primary key. If you don't specify
one, the system will pick one for you automatically.

//Magnus

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2007-11-06 11:06:44 Re: How to create primary key
Previous Message Samantha Atkins 2007-11-06 09:38:31 Re: How to create primary key