ALTER TABLE ... ADD constraint

From SQLZoo

Add a constraint to a table.

schema:scott

We can add a constraint

  • a foreign key reference
  • a UNIQUE requirement
  • a CHECK constraint

This is in the SQL standard ALTER TABLE

DROP TABLE a
CREATE TABLE a(x INTEGER, y INTEGER);
INSERT INTO a VALUES (1,2);
ALTER TABLE a ADD CHECK (y>0)