![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, Is there a way to make postgresql report an error if when inserting data, a multiple-column combination is duplicated? CREATE TABLE parts_vendors ( part_id integer references parts (part_id), vendor_id integer references vendors (vendor_id), ... ) part_id vendor_id ------------------ 1 3 2 5 <--+ 7 9 | 2 5 <--+-- duplicate pattern ... |
#3
| |||
| |||
|
|
Hi, Is there a way to make postgresql report an error if when inserting data, a multiple-column combination is duplicated? |
#4
| |||
| |||
|
|
Russell Shaw wrote: Hi, Is there a way to make postgresql report an error if when inserting data, a multiple-column combination is duplicated? CREATE TABLE parts_vendors ( part_id integer references parts (part_id), vendor_id integer references vendors (vendor_id), ... ) part_id vendor_id ------------------ 1 3 2 5 <--+ 7 9 | 2 5 <--+-- duplicate pattern ... Oops, i can just do a select on the various columns to detect this... ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org) |
#5
| |||
| |||
|
|
On Feb 1, 2004, at 6:06 PM, Russell Shaw wrote: Hi, Is there a way to make postgresql report an error if when inserting data, a multiple-column combination is duplicated? I believe you're looking for UNIQUE(part_id, vendor_id), if you want to prevent this from happening. If you just want it to report an error, but allow the insert/update anyway, maybe a trigger? Not sure about that though. |
![]() |
| Thread Tools | |
| Display Modes | |
| |