Previous Topic: Maintaining Referential ConstraintsNext Topic: Dropping a Referential Constraint


Creating a Referential Constraint

To create an unlinked or linked referential constraint, use the SQL DDL CREATE CONSTRAINT statement. CA IDMS/DB checks and rejects any invalid CREATE CONSTRAINT statements.

Considerations

Example

In the following example, a linked referential constraint has been created to make sure that the employee ID in the benefits table is a valid ID by checking it against the employee IDs in the employee table. The referential constraint is indexed and ordered by the fiscal year.

create constraint emp_benefits
   benefits (emp_id)
   references employee (emp_id)
   linked index
     order by (fiscal_year desc);