Disable a constraint (ADP)

Microsoft Office Access 2003

Select the option to disable a foreign key constraint during INSERT and UPDATE transactions if you know that new data will violate the constraint or if the constraint applies only to the data already in the database.

  1. In the Database window, click Database Diagrams Button image under Objects, click the database diagram you want to open, and then click Design on the Database window toolbar.
  2. In your database diagram, right-click the table containing the foreign key, then select Relationships from the shortcut menu.
  3. Select the relationship from the Selected relationship list.
  4. Clear the Enforce relationship for INSERTs and UPDATEs check box.

After you add or modify data, you should select this option if you want to ensure the constraint applies to subsequent data modifications.

Note   If you plan to use triggers to implement database operations, you must disable foreign key constraints in order for the trigger to run.

ShowDisable a check constraint with INSERT or UPDATE Statements

ShowBackground information

You can disable a check constraint when data is added to, updated in, or deleted from a table. Disabling a constraint enables you to perform the following transactions:

  • Add a new row of data to a table (using the INSERT statement) where the existing rows were required to meet specific business rules that no longer apply. For example, you may have required postal codes to be limited to five digits in the past, but now want new data to allow nine-digit postal codes. Old data with five-digit postal codes will coexist with new data that contains nine-digit postal codes.
  • Modify existing rows (using the UPDATE statement) where the existing rows were required to meet specific business rules that no longer apply. For example, you may want to update all existing five-digit postal codes to nine-digit postal codes.

Select the option to disable a check constraint during INSERT and UPDATE transactions if you know that new data will violate the constraint, or if the constraint applies only to the data already in the database.

ShowDisable a check constraint with INSERT and UPDATE statements

  1. In the Database window, click Database Diagrams Button image under Objects, click the database diagram you want to open, and then click Design on the Database window toolbar.
  2. In your database diagram, right-click the table containing the constraint, then select Properties from the shortcut menu.
  3. Choose the Check Constraints tab.
  4. Select the constraint from the Selected constraint list.
  5. Clear the Enforce constraint for INSERTs and UPDATEs check box.

    You can select this option after you add or modify data to guarantee that the constraint applies to subsequent data modifications.

ShowDisable a foreign key constraint for replication

Microsoft SQL Server supports replication. Select the option to disable a foreign key constraint during replication if the constraint is specific to the source database and may unnecessarily prevent new data from being entered into the destination database.

  1. In the Database window, click Database Diagrams Button image under Objects, click the database diagram you want to open, and then click Design on the Database window toolbar.
  2. In your database diagram, right-click the table containing the foreign key, then select Properties from the shortcut menu.
  3. Choose the Relationships tab.
  4. Select the relationship from the Selected relationship list.
  5. Clear the Enforce relationship for replication check box.

ShowDisable a check constraint for replication

You can disable a check constraint when your table is replicated in another database. When you replicate a table, the table definition and data are copied from the source database to a destination database. These two databases are usually (but not necessarily) on separate servers. If the check constraints are specific to the source database, they may unnecessarily prevent new data from being entered in the destination database. When you replicate a database at a remote site, you should not reapply check constraints because:

  • The integrity of the data was checked when it was entered into the original database.
  • The replication will fail if data violates the check constraints.
  1. In the Database window, click Database Diagrams Button image under Objects, click the database diagram you want to open, and then click Design on the Database window toolbar.
  2. In your database diagram, right-click the table containing the constraint, then select Properties from the shortcut menu.
  3. Choose the Check Constraints tab.
  4. Select the constraint from the Selected constraint list.
  5. Clear the Enforce constraint for replication check box.