The NOT NULLconstraint 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 :
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
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: