Jump to content


Not Null And Default

  • Please log in to reply
No replies to this topic

#1 Kurosaki_Ichigo


    New Member

  • Members
  • Pip
  • 2 posts

Posted 13 May 2015 - 06:18 PM



Towards the end of chapter 1 under the sub-topic "Default Values" there is this example - 

CREATE TABLE doughnut_list
doughnut_name VARCHAR (10) NOT NULL,
doughnut_type VARCHAR (6) NOT NULL,
doughnut_cost DEC(3,2) NOT NULL DEFAULT 1.00

I have a doubt in line (3) of the SQL query - 


The definition of NOT NULL - All columns should have a value 


The definition of Default - If no value is passed then it considers a default value in this case 1.00 


I think NOT NULL and DEFAULT are contradicting each other here, if the user has to provide a value (NOT NULL) then the need for DEFAULT will never arise. So I guess, DEFAULT command must be used minus the NOT NULL 


Please correct me if I am wrong.



Thanks in advance.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users