Thread: Primary key
Hello, 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. Carol
--- 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.
On 19 sep 2007, at 16.37, Carol Walter 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. Yes, it does. http://www.postgresql.org/docs/8.2/interactive/ddl- constraints.html#AEN2080 Sincerely, Niklas Johansson
Yes, PG allows compound or composite keys for primary keys. Igor -----Original Message----- From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Carol Walter Sent: Wednesday, September 19, 2007 10:37 AM To: pgsql-admin@postgresql.org Subject: [ADMIN] Primary key Hello, 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. Carol ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings