You are here: Re: How do I set defaults? « PHP SQL « IT news, forums, messages
Re: How do I set defaults?

Posted by J.O. Aho on 10/04/58 11:39

Tony Peardon wrote:
> Its simple, really. I've got a table called name which holds, you guessed
> it, names. The fields are prefix, first, middle, last, and suffix. Only a
> persons first name need be included, as all other fields can be null, but I
> don't want them to be null by default. I want them set to an empty string by
> default instead. Null will be used to signify that a person does not have
> part of the name, while the empty string will signify only that the database
> doesn't yet know the information. I know this is easy, but I'm doing
> something wrong. Could someone please clear this up for me.
>
> Here's a line of relevant code...
>
> alter table name add column suffix varchar(5) null default('');

ALTER TABLE name ADD suffix VARCHAR(5) DEFAULT '';


> so what is the matter with that?
>
> also, assuming that suffix already exists within table name, what would the
> sql be to just add a default to it?

ALTER TABLE name MODIFY suffix VARCHAR(5) DEFAULT '';

http://dev.mysql.com/doc/refman/5.0/en/alter-table.html


//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация