MySQL Forums
Forum List  »  Newbie

NOT NULLs with default '' ??
Posted by: Erin ONeill
Date: July 19, 2005 04:52PM

I'm cleaning up a database but I see this all over the MySQL world. I understand that having defaults speeds things up. But what I don't understand is why someone would make a field NOT NULL and then put a null default in it?? This makes no sense to me at all. Is this the fault of using phpMyAdmin to create tables?

Here's a sample:
CREATE TABLE `listnames` (
`id` int(11) NOT NULL auto_increment,
`list_name` char(30) NOT NULL default '',
`display_name` char(100) NOT NULL default '',
`active` char(3) NOT NULL default '',
`last_modified` timestamp(14) NOT NULL,
UNIQUE KEY `id` (`id`)
)

Ok, so you don't want NULLs in your data but there is no default. It's very likely that the data will be wildly differently. So setting a default makes no sense -- or does it??

This is driving me nuts -- I don't want to drop the default '' if it makes sense & I'm just not getting it.

Anyone?

thanks,
erin

Options: ReplyQuote


Subject
Written By
Posted
NOT NULLs with default '' ??
July 19, 2005 04:52PM


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.