Re: Primary key - Mailing list pgsql-admin

From Richard Broersma Jr
Subject Re: Primary key
Date
Msg-id 558465.79884.qm@web31808.mail.mud.yahoo.com
Whole thread Raw
In response to Primary key  (Carol Walter <walterc@indiana.edu>)
List pgsql-admin
--- Carol Walter <walterc@indiana.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:
http://www.postgresql.org/docs/8.2/interactive/sql-createtable.html

This link illistrates syntax with this example:

CREATE TABLE films (
    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)
);

Regards,
Richard Broersma Jr.

pgsql-admin by date:

Previous
From: Carol Walter
Date:
Subject: Primary key
Next
From: Niklas Johansson
Date:
Subject: Re: Primary key