Skip site navigation (1) Skip section navigation (2)

Re: Primary key

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Carol Walter <walterc(at)indiana(dot)edu>, pgsql-admin(at)postgresql(dot)org
Subject: Re: Primary key
Date: 2007-09-19 15:26:15
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
--- Carol Walter <walterc(at)indiana(dot)edu> wrote:

> Does postgres allow compound or composite keys for primary keys?  I  
> thought I read someplace that it didn't.  Now, I can't find a  
> reference to it.

It does.  composite key are defined as a table constraint:

This link illistrates syntax with this example:

    code        char(5),
    title       varchar(40),
    did         integer,
    date_prod   date,
    kind        varchar(10),
    len         interval hour to minute,
    CONSTRAINT code_title PRIMARY KEY(code,title)

Richard Broersma Jr.

In response to

pgsql-admin by date

Next:From: Igor NeymanDate: 2007-09-19 16:35:57
Subject: Re: Primary key
Previous:From: Niklas JohanssonDate: 2007-09-19 15:20:54
Subject: Re: Primary key

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group