Adding and removing domain-level CHECK
constraints
If the domain doesn’t have a CHECK
constraint yet, you can add one like this:
alter domain MyDomain add constraint check (value is not null)
You may leave out the constraint
keyword if you wish.The added CHECK
takes effect immediately for all the columns that are based on the domain.However, the check is only applied to new updates and inserts;existing NULL
data will remain in place and will continue to be shown as <null>
in result sets.
A domain can have at most one CHECK
constraint.There is no ALTER CHECK
statement;if you want to change the CHECK
, you must drop it and create a new one.
This is how you drop a CHECK
constraint from a domain:
alter domain MyDomain drop constraint
You must close all connections and reconnect before you can insert values that would have violated the dropped CHECK
in MyDomain-based columns.