DEFAULT NOT NULL

If you have a column with NOT NULL restriction and at the same time this same column provided a DEFAULT value, then you can’t insert NULL explicitly into this column. See below

As you can see Oracle won’t insert NULL specified explicitly in VALUE clause.

But, if you try to insert an implicit NULL when it is ok. In this regard, we may need another column called first_name added to the table

 

We have just inserted a NULL value implicitly into text column, let’s verify

As we can see a new value ‘Vlad’ has been added to the first_name column, while ‘sql’ DEFAULT value has been added implicitly to the text column.

Conclusion: DEFAULT .. NOT NULL clause prevents Oracle from inserting NULL value explicitly through insert statement. at the same time allows it implicitly

 

Leave a comment

Your email address will not be published. Required fields are marked *