Check constraint on existing column with PostgresQL

Use alter table to add a new constraint:

alter table foo 
   add constraint check_positive check (the_column > 0);

More details and examples are in the manual:
http://www.postgresql.org/docs/current/static/sql-altertable.html#AEN70043

Edit

Checking for specific values is done in the same way, by using an IN operator:

alter table foo 
   add constraint check_positive check (some_code in ('A','B'));

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)