Here’s sample SQL query for how to write NOT NULL column constraint correctly. Before you go into details, NULL value means, it does not have value ( or you can say un-known).
NOT NULL is column-constraint. You would need to supply value always.
Best Example
Create Table Artist
(artist_id int not null,
dob date not null,
salary int);
So the artist table does not allow null values for artist_id and dob. You must enter values.
Here’s audio talk on SQL NOT NULL
The salary column is different, where it allows null values when you do not enter any amount.
Table Data of Artist
| artist_id | DOB | Salary |
| 1001 | 2000-01-19 | 10000 |
| 1002 | 2001-07-20 | <null> |
| 1003 | 2003-05-15 | <null> |
Summary
- NOT NULL is a column constraint
- Without values in the columns where NOT NULL defines, the SQL gives errors.
- By default, all the columns accept NULL values
Related Posts







One response
[…] NOT NULL columns you must supply […]
LikeLike