How to Use NOT NULL Column Constraint Correctly

IN THIS POST, I have explained how to write NOT NULL column “constraint” correctly. Before that, a NULL value means you have not supplied any value or un-known.


NOT NULL is a column constraint. So that user need to enter some value.

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.

SQL NOT NULL Audio

The salary column is different, where it allows null values when you do not enter any amount.

Table Data of Artist

artist_idDOBSalary
10012000-01-1910000
10022001-07-20<null>
10032003-05-15<null>

Summary

  1. NOT NULL is a column constraint
  2. Without values in the columns where NOT NULL defines, the SQL gives errors.
  3. By default, all the columns accept NULL values

Related Posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.

Comments are closed.