Re: [GENERAL] Multicolumn primary key with null value

2010-04-23 Thread Craig Ringer
On 23/04/10 15:50, Adrian von Bidder wrote: On Friday 23 April 2010 03.27:29 Craig Ringer wrote: insert into test (a,b) values ('fred',NULL); insert into test (a,b) values ('fred',NULL); ... and will succeed: Hmm. Perhaps not as ugly as "none" placeholders: create unique index on test (b)

Re: [GENERAL] Multicolumn primary key with null value

2010-04-23 Thread Adrian von Bidder
On Friday 23 April 2010 03.27:29 Craig Ringer wrote: > insert into test (a,b) values ('fred',NULL); > insert into test (a,b) values ('fred',NULL); > > > ... and will succeed: Hmm. Perhaps not as ugly as "none" placeholders: create unique index on test (b) where a is null; create unique index o

Re: [GENERAL] Multicolumn primary key with null value

2010-04-22 Thread Craig Ringer
On 23/04/2010 1:42 AM, Said Ramirez wrote: Primary keys are defined as 'unique not null' even if they are composite. So I believe postgres would not let you do that You can, however, add a UNIQUE constraint on the column set as a whole. PostgreSQL does *not* enforce non-null in this case, so s

Re: [GENERAL] Multicolumn primary key with null value

2010-04-22 Thread Said Ramirez
Primary keys are defined as 'unique not null' even if they are composite. So I believe postgres would not let you do that: 5.3.4. Primary Keys Technically, a primary key constraint is simply a combination of a unique constraint and a not-null constraint. A primary key indicates that a c

[GENERAL] Multicolumn primary key with null value

2010-04-22 Thread Szymon Guz
Does any SQL standard allows for a multicolumn primary key where in one record there is a null in on of the primary key columns? regards Szymon Guz

[GENERAL] Multicolumn Primary Key

2004-08-31 Thread Thomas F . O'Connell
We've got a table that has a definition as follows: CREATE TABLE linking_table ( fk int8 REFERENCES source_table( pk1 ), value int8, PRIMARY KEY( fk1, value ) ); I would've thought that the multicolumn primary key would behave as a multicolumn index is supposed to behave per http://www.postgres