The NOT NULL constraint enforces a column to NOT accept NULL values.
The NOT NULL constraint enforces a field to always contain a value. This means that you cannot insert a new record, or update a record without adding a value to this field.
The following SQL enforces the "U_Id" column and the "LastName" column to not accept NULL values:
CREATE TABLE Users
(
U_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)
--when we want insert null value lastname get error
insert into Users(U_Id,LastName,FirstName,Address,City)
values(1011,null,'Ravi','mumbai','thane')
When I insert lastname null get error.
Result :
Liked By
Write Answer
SQL NOT NULL Constraint
Join MindStick Community
You have need login or register for voting of answers or question.
Anonymous User
03-Nov-2015The NOT NULL constraint enforces a column to NOT accept NULL values.
The NOT NULL constraint enforces a field to always contain a value. This means that you cannot insert a new record, or update a record without adding a value to this field.
The following SQL enforces the "U_Id" column and the "LastName" column to not accept NULL values: