As the expression "non-null constraint" means, if a non-null constraint is added to a field, we cannot update the value in this field to null. The Famount field of the T_DEBT table has a non-null constraint, if we execute the following sql:
UPDATE T_Debt set FAmount = NULLWHERE FPerson="Tom"
This SQL sets a null value for Famount. After we execute this SQL, the database system will report an error message similar to the following:
You cannot insert a value of NULL into the column "Famount", the Table "Demo.dbo.T_Debt", and the column does not allow null values. Update failed.
If we set a non-null value for Famount, it will be inserted successfully and execute the following sql:
UPDATE T_Debt set FAmount =123WHERE FPerson="Tom"
This sentence of SQL can be successfully executed correctly. Perform a SELECT * from t_debt to view the data in the table:
You can see that the data has been updated correctly in the table.
The effect of non-null constraints on data update