Re: Primary key

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



--- Carol Walter <walterc@xxxxxxxxxxx> 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.

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux