Rayben Posted January 19, 2007 Share Posted January 19, 2007 Hi! I've been working with MySQL for a few months now with the help of online tutorialsand I've noticed that everyone allways sets columns to NOT NULL. Why is that?I can't see any reason to do that in general. However, being a semi-noob I get a little nervous from time to timethinking that I've missed something about this NOT NULL property that will come back and bite me in the butt just as I completed a major project.Any comments? Or can I just skipp "NOT NULL"'ing stuff? Quote Link to comment Share on other sites More sharing options...
effigy Posted January 19, 2007 Share Posted January 19, 2007 Keep in mind that NULL is truly nothing, whereas "" is an empty string. NULLs are useful for fields that are not required. For example, if your table has a foreign key constraint, but a relationship is not required, you cannot use "" or 0: the field has to be NULL. Quote Link to comment Share on other sites More sharing options...
fenway Posted January 22, 2007 Share Posted January 22, 2007 Unless you need NULL, don't bother having it... I really need to write a sticky on this topic, I keep answering it over & over again (but not recently enough, apparently). If you don't have to distinguish between blank/zero and "nothing", like effigy said, then no, you don't need it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.