• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Defining Check Constraints

Constraints are a way of limiting the values that can be entered in a column or group of columns. Constraints are handy because you can use them to enforce data consistency from your users and ensure the relational integrity of your database. You might already be familiar with some of these constraints. Access projects use a group of constraints to create elements in the table design interface that are familiar to Access desktop database (.mdb) users. These elements include the ability to specify a default value in a column, declaring primary and foreign keys, and creating a table index as a unique index.

Access projects also include the ability to create additional custom constraints called check constraints for the columns you create in your tables. Check constraints are similar to Access desktop database table and field validation rules. You can define constraints to ask the database to check the values of a column (or a group of columns) before the database saves a row to make sure they meet the criteria you specified. Check constraints differ from validation rules because they are applied to the whole row when the row is added or updated. If you enter a value that fails a check constraint criterion, you won’t see the validation message until you try to save the row. SQL Server evaluates check constraints in the order that you created them on the table. Let’s take a look at how to create a check constraint.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint