Say I have a constraint
ALTER TABLE distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 5);
that needs to be modified so that zipcode length is 6
.
Do I have the drop the constraint zipchk
first and then recreate it ?
ALTER TABLE distributors DROP CONSTRAINT zipchk;
ALTER TABLE distributors ADD CONSTRAINT zipchk CHECK (char_length(zipcode) = 6);
or is there a MODIFY
(like) command :
ALTER TABLE distributors MODIFY CONSTRAINT zipchk CHECK (char_length(zipcode) = 6);
modify
constraint (which is clearly documented in the manual). You need to drop and re-create it.ALTER CONSTRAINT
in 9.4 but only works for foreign key constraints. postgresql.org/docs/current/static/sql-altertable.html