Vinod Viswanathan wrote:

I have a table with an btree unique index over 4 varchar keys.
When I insert and if one or more keys is null, postgres allows
duplicate rows to be inserted into the table.
Are there some issues if index keys are null.

NULLs don't count against UNIQUE constraints, even if multi-column. See end of this section:


http://www.postgresql.org/docs/7.3/interactive/ddl- constraints.html#AEN1835

As far as I know, there is no simple way to override this - that is, no constraint allowing at most one NULL in a column. Same for your four-column constraint, I believe. You could get what you want by using another NULL-like value, e.g., an empty string ''. You might be able to use a trigger, too. - I have little experience with those.

- John Burger
  MITRE



---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
     subscribe-nomail command to [EMAIL PROTECTED] so that your
     message can get through to the mailing list cleanly

Reply via email to