MySQL Forums
Forum List  »  Newbie

Re: quickie.. query from version 3 into version 4.1?
Posted by: Erin ONeill
Date: July 26, 2005 10:50PM

>I'm curious, why are 0 or the empty string 'bad' default values? I'd say the meaning of your column >determines wheter these are appropriate default values.

>Surely, 0 or '' are not basically the same as NULL (although mysql uses these as NULL substitutes), or >are they? I always thought that NULL is not really a value, it's more like a marker saying 'Nope, no >value here' or 'value not specified', whereas 0 and '' are actual values.

Ok, I have a field called written_by. In the table context I'd expect that to be either a username or a uid. The datatype was varchar so I'm left to believe that it'll be a username. BUT the table was created with default ''. The programmer wasn't forced to really put a value in this. So a '' was in ALL the rows for this field. There were no usernames - no nothing.

ANd when I do this

SELECT somefield FROM table WHERE written_by NOT NULL - gives me ALL the rows. Yet looking at the data ALL of the rows are really NULL.

Tell me how this is good? If I'd forced it and said NOT NULL but gave no default (which to tell you the truth there should be NO DEFAULT in this situation because the data should be extremely varied) then the programmer would have been required to enter data. I need the data. I don't have it.

Tell me how this is good?

Ok it's a pet peeve of mine (and I've found out I'm not the only one! :) ).

erin - off the soap box!

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.