I've created unique index smth. like this
create unique index port_uidx ON port USING btree (device_id, lower(name), parent_id);
But now I wanna exclude one of fields, for example parent_id What should I do in this case? I need to save unique index without parent_id.
P.S. One more thing, there are duplicates migth be. This point needs to be taken into
Thank you
Clean up the table so that it no longer violates the unique constraint you want to add, then add it. Instead of just wiping the violating rows, you can move them elsewhere using
delete...returningclause: demoYou can rely on
ctidwhen you combine statements into one, but don't expect it to be stable between separate, even consecutive queries.