RefLib

Reference library for AI

Back

postgresql_16:7.1.7.4 Examples

PostgreSQL 16 > Reference > SQL Commands > ALTER DOMAIN > Examples

To add a NOT NULL constraint to a domain: ALTER DOMAIN zipcode SET NOT NULL; To remove a NOT NULL constraint from a domain: ALTER DOMAIN zipcode DROP NOT NULL;

To add a check constraint to a domain: ALTER DOMAIN zipcode ADD CONSTRAINT zipchk CHECK (char_length(VALUE) = 5);

To remove a check constraint from a domain: ALTER DOMAIN zipcode DROP CONSTRAINT zipchk;

To rename a check constraint on a domain: ALTER DOMAIN zipcode RENAME CONSTRAINT zipchk TO zip_check;

To move the domain into a different schema: ALTER DOMAIN zipcode SET SCHEMA customers;

Back