List:General Discussion« Previous MessageNext Message »
From:Daniel Koch Date:June 30 1999 8:45pm
Subject:Re: problems with DEFAULT statement in MySQL 3.22.23b
View as plain text  
Tim McQueen wrote:

> I'm having problems assigning default values when I create a table.  For instance, if
> I have a table:
>
> create table foo (
>     user char(16) NOT NULL,
>     passwd char(16) DEFAULT  'password' NOT NULL,
>     PRIMARY KEY (user)
> );
>
> and INSERT the values ('joeuser','')
>
> shouldn't it populate the table with the values ('tmcqueen','password') ?
>
> Thanks in advance for any help.
>
> Tim McQueen
> tmcqueen@stripped

You're explicity inserting an empty string (''), which MySQL is using instead of the
default.

To get it to use the default, don't name the passwd column in your insert.  e.g.:

    insert into foo (user) values ('joeuser')

See section 7.13 of the manual.

Regards,

--
Dan Koch
Webmaster
American City Business Journals
http://www.amcity.com/


Thread
problems with DEFAULT statement in MySQL 3.22.23bTim McQueen1 Jul
  • Re: problems with DEFAULT statement in MySQL 3.22.23bT├Ánu Samuel1 Jul
  • Re: problems with DEFAULT statement in MySQL 3.22.23bSasha Pachev1 Jul
  • Re: problems with DEFAULT statement in MySQL 3.22.23bDaniel Koch1 Jul
RE: problems with DEFAULT statement in MySQL 3.22.23bdaniel.gardner1 Jul