![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello there, I need to enforce a unique constraint on 2 colums of a table (both of them are not primary keys). I mean that 2 rows are different when at least one of the two above columns is different. The problem is that Postgres enforce the constraint also when only one of the columns is equal to another row, see below the creation code i used for: alter table interfaces add constraint if_uniq unique (name, device); but this constraint raise an error when, for example i try to insert two rows with values: insert into interfaces (name, device) values ('141', 646); insert into interfaces (name, device) values ('141', 637); is this a bug in Postgres? is there a solution? |
#3
| |||
| |||
|
|
Hello there, I need to enforce a unique constraint on 2 colums of a table (both of them are not primary keys). I mean that 2 rows are different when at least one of the two above columns is different. The problem is that Postgres enforce the constraint also when only one of the columns is equal to another row, see below the creation code i used for: alter table interfaces add constraint if_uniq unique (name, device); but this constraint raise an error when, for example i try to insert two rows with values: insert into interfaces (name, device) values ('141', 646); insert into interfaces (name, device) values ('141', 637); is this a bug in Postgres? is there a solution? |
#4
| |||
| |||
|
|
Hello there, I need to enforce a unique constraint on 2 colums of a table (both of them are not primary keys). I mean that 2 rows are different when at least one of the two above columns is different. The problem is that Postgres enforce the constraint also when only one of the columns is equal to another row, see below the creation code i used for: alter table interfaces add constraint if_uniq unique (name, device); but this constraint raise an error when, for example i try to insert two rows with values: insert into interfaces (name, device) values ('141', 646); insert into interfaces (name, device) values ('141', 637); is this a bug in Postgres? is there a solution? |
#5
| |||
| |||
|
|
Hello there, I need to enforce a unique constraint on 2 colums of a table (both of them are not primary keys). I mean that 2 rows are different when at least one of the two above columns is different. The problem is that Postgres enforce the constraint also when only one of the columns is equal to another row, see below the creation code i used for: alter table interfaces add constraint if_uniq unique (name, device); but this constraint raise an error when, for example i try to insert two rows with values: insert into interfaces (name, device) values ('141', 646); insert into interfaces (name, device) values ('141', 637); is this a bug in Postgres? is there a solution? |
#6
| |||
| |||
|
|
Hello there, I need to enforce a unique constraint on 2 colums of a table (both of them are not primary keys). I mean that 2 rows are different when at least one of the two above columns is different. The problem is that Postgres enforce the constraint also when only one of the columns is equal to another row, see below the creation code i used for: alter table interfaces add constraint if_uniq unique (name, device); but this constraint raise an error when, for example i try to insert two rows with values: insert into interfaces (name, device) values ('141', 646); insert into interfaces (name, device) values ('141', 637); is this a bug in Postgres? is there a solution? |
#7
| |||
| |||
|
|
Hello there, I need to enforce a unique constraint on 2 colums of a table (both of them are not primary keys). I mean that 2 rows are different when at least one of the two above columns is different. The problem is that Postgres enforce the constraint also when only one of the columns is equal to another row, see below the creation code i used for: alter table interfaces add constraint if_uniq unique (name, device); but this constraint raise an error when, for example i try to insert two rows with values: insert into interfaces (name, device) values ('141', 646); insert into interfaces (name, device) values ('141', 637); is this a bug in Postgres? is there a solution? |
#8
| |||
| |||
|
|
Hello there, I need to enforce a unique constraint on 2 colums of a table (both of them are not primary keys). I mean that 2 rows are different when at least one of the two above columns is different. The problem is that Postgres enforce the constraint also when only one of the columns is equal to another row, see below the creation code i used for: alter table interfaces add constraint if_uniq unique (name, device); but this constraint raise an error when, for example i try to insert two rows with values: insert into interfaces (name, device) values ('141', 646); insert into interfaces (name, device) values ('141', 637); is this a bug in Postgres? is there a solution? |
#9
| |||
| |||
|
|
Hello there, I need to enforce a unique constraint on 2 colums of a table (both of them are not primary keys). I mean that 2 rows are different when at least one of the two above columns is different. The problem is that Postgres enforce the constraint also when only one of the columns is equal to another row, see below the creation code i used for: alter table interfaces add constraint if_uniq unique (name, device); but this constraint raise an error when, for example i try to insert two rows with values: insert into interfaces (name, device) values ('141', 646); insert into interfaces (name, device) values ('141', 637); is this a bug in Postgres? is there a solution? |
#10
| |||
| |||
|
|
I need to enforce a unique constraint on 2 colums of a table (both of them are not primary keys). I mean that 2 rows are different when at least one of the two above columns is different. The problem is that Postgres enforce the constraint also when only one of the columns is equal to another row, see below the creation code i used for: alter table interfaces add constraint if_uniq unique (name, device); but this constraint raise an error when, for example i try to insert two rows with values: insert into interfaces (name, device) values ('141', 646); insert into interfaces (name, device) values ('141', 637); is this a bug in Postgres? is there a solution? |
|
can you post the definition of your table, so we can see what's <unknown> to us? CREATE TABLE interfaces ( unknown CONSTRAINT if_uniq UNIQUE (name, device) ) ; |
![]() |
| Thread Tools | |
| Display Modes | |
| |