This statement is especially useful after applying a constraint to an existing column via
ADD CONSTRAINT. In this case,
VALIDATE CONSTRAINT can be used to find values already in the column that do not match the constraint.
The user must have the
CREATE privilege on the table.
||The name of the table in which the constraint you'd like to validate lives.|
||The name of the constraint on
> ALTER TABLE orders ADD CONSTRAINT customer_fk FOREIGN KEY (customer_id) REFERENCES customers (id) ON DELETE CASCADE;
In order to ensure that the data added to the
orders table prior to the creation of the
customer_fk constraint conforms to that constraint, run the following:
> ALTER TABLE orders VALIDATE CONSTRAINT customer_fk;
If present in a
CREATE TABLE statement, the table is considered validated because an empty table trivially meets its constraints.