Constraints are used to specify rules for the data in a table. Constraints can be specified when the table is created with the Constraints.Add method.
- Constraints are used to limit the type of data that can go into a table.
- This ensures the accuracy and reliability of the data on the table.
- If there is any violation of the constraint and the data action, the action is aborted.
To limit the length of any string column, use NCharConstraint and pass the column name, and it’s desired length as an argument.
Not Null Constraint
Ensures that a column cannot have a NULL value. Use NotNullableConstraint to make any column not nullable.