Thread: Concept of NULL
View Single Post
Old December 29th, 2010, 10:17 AM
rseni rseni is offline
Registered User
Join Date: Nov 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Concept of NULL

Hy Guys,

Beginning with mysql. I am not able to grasp the concept of NULL. Check flickr screen-shots. In it when I specifically declared 'name' field to be NOT NULL. When i run the 'desc test' table command, the table description shows default value for name field to be NULL.Why is that so?

From what I have read about NULL, it connotes a missing or information that is not applicable. So when I declare a field to be NOT NULL it implies (as per my understanding) that user must enter a value for the name field else the DB engine should generate an error i.e. record will not be entered in DB. However when i run 'insert into test value();' the DB engine enters the record in table. Check flickr screen-shot(second-one).

FLICKR LINKS *declare_not_null*

*empty_values* Check the second screenshot on flickr

Q.2 what would be sql statement to drop a primary key from a table's field. If I use 'ALTER TABLE test drop key id;' it gives the following:

ERROR: Incorrect table definition; there can be only one auto column and it must be defined as a key.

Thanks for your help.