Setting up constraints for your database
You can use physical file constraints to control data integrity in your database. You can add constraints using the Add Physical File Constraint (ADDPFCST) command or iSeriesā¢ Navigator.
To add a physical file constraint, use the ADDPFCST command.
- To add a unique constraint, specify a value of *UNQCST on the Type parameter.
You must also specify one or more field names for the Key parameter.
- To add a primary key constraint, specify a value of *PRIKEY on the Type parameter. The key that you specify on the command becomes the primary access path of the file. If the file does not have a keyed access path that can be shared, the system creates one. You must also specify one or more field names for the Key parameter.
- To add a check constraint, specify a value of *CHKCST on the Type parameter.
You must also specify a check constraint expression on the CHKCST parameter.
The check constraint expression has the same syntax as the expression used for check-conditions that are defined using Structured Query Language (SQL).
For information about using SQL to set up constraints, see DB2 Universal Databaseā¢ for iSeries SQL Reference.
You can also add constraints using iSeries Navigator. See the following topics in the SQL programming topic:
- Add key constraints using iSeries Navigator
- Add check constraints using iSeries Navigator
You can also add constraints when using the SQL CREATE TABLE and ALTER TABLE statements.