Thread: [SQL] composite primary keys.

[SQL] composite primary keys.

From
Stuart Rison
Date:
Dear All,

Does postgreSQL 6.3.2 support composite primary keys?  If so, how do you
implement these?

If postgreSQL does not support them (yet? ;) ), has anybody come up with a
'fudge' to 'immitate' them?

Could you please cc any postings to stuart@ludwig.ucl.ac.uk.

Best regards,

Stuart.


+-------------------------+--------------------------------------+
| Stuart Rison            | Ludwig Institute for Cancer Research |
+-------------------------+ 91 Riding House Street               |
| Tel. (0171) 878 4041    | London, W1P 8BT, UNITED KINGDOM.     |
| Fax. (0171) 878 4040    | stuart@ludwig.ucl.ac.uk              |
+-------------------------+--------------------------------------+



Re: [SQL] composite primary keys.

From
Dave
Date:
> Dear All,
>
> Does postgreSQL 6.3.2 support composite primary keys?  If so, how do you
> implement these?

Let me know if I understand...

Do you want to build primary keys with more than one element ???

Try with:

    create table t1 ( field1 int, field2 int, field3 int,
                      primary key (field1,field2));

The primary key can contain as many elements as you want. But if what you
want is to activate referential integrity constraints, read about SPI in
your documentation.

Buena Suerte Amigo !!

_______________________________________
David Martinez Cuevas
Direccion General de Estadistica, UNAM - Mexico
Tel. 622-60-80
E-mail david@estadistica.unam.mx
----------------------------------------