I have the table create as
create table public.test
(
val int unique not null
)
This table contains some rows
| Val |
|--------|
|1 |
|2 |
|3 |
|4 |
|5 |
|6 |
|7 |
|8 |
|9 |
I wanna increment all values greater then 5 (using PostgreSQL). But if try update public.test set val=val+1 where val > 5 i will get exception:
ERROR: duplicate key value violates unique constraint "test_val_key" DETAIL: Key (val)=(7) already exists.
How i can do this?