Named Constraints
If the constraint name is omitted, the DBMS Server assigns a name.
To assign a name to a constraint on the ALTER TABLE statement, use the following syntax:
ALTER TABLE table_name ADD CONSTRAINT constraint_name constraint_clause
The keyword CONSTRAINT must be used only when specifying a name.
For example, the following statement adds a named constraint to the dept table:
ALTER TABLE dept ADD CONSTRAINT dept_unique UNIQUE(name);
The following statement adds an internally named constraint to the dept table:
ALTER TABLE dept ADD UNIQUE(name);
To drop a constraint, using the following syntax:
ALTER TABLE table_name DROP CONSTRAINT constraint_name RESTRICT
For example, the following ALTER TABLE statement drops the constraint named dept_unique:
ALTER TABLE dept DROP CONSTRAINT dept_unique RESTRICT;
To find a system-defined constraint name:
HELP CONSTRAINT table_name;
You can also use the following:
SELECT * FROM iiconstraints WHERE table_name = table_name;
If a system-defined constraint name is being dropped, specify the constraint name using a delimited identifier (that is, in double quotes), because system-defined constraint names include special characters.
Last modified date: 06/28/2024