As the expression "non-null constraint" means, if a non-null constraint is added to a field, we cannot insert a null value into this field. The Famount field of the T_DEBT table has a non-null constraint, if we execute the following sql:
INSERT INTO T_Debt (FNumber, FPerson) VALUES ("1", "Jim")
This SQL does not assign a value to the field Famount, that is, Famount is a null value. 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. Insert failed.
If we set a non-null value for Famount, it will be inserted successfully and execute the following sql:
INSERT into T_debt (Fnumber,famount, Fperson) VALUES ("1", "$", "Jim")
This sentence of SQL can be successfully executed correctly. Perform a SELECT * from t_debt to view the data in the table:
The effect of non-null constraints on data insertion