When to manually set constraint checking for a table

Typically, you need to manually set constraint checking for a table in three situations: after loading data into a table, when altering a table by adding constraints on the table, and when altering a table to add a generated column.

The load operation causes a table to be put into check pending state automatically if the table has check or foreign key constraints defined on it. When the load operation is completed, you can turn on constraint checking for the table.

If you are altering a table by adding a foreign key, or by adding a generated column, you need to turn off constraint checking before you alter the table. After you add the foreign key, you need to turn constraint checking back on.

If you want to alter a table by adding a generated column, you need to turn off constraint checking before adding the column. In addition, if you are loading data into the table, you cannot activate constraint checking on the table until you complete loading data into it. If you are importing data into the table, you should activate constraint checking on the table before you import data into it.