[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql
Subject:    Re: problems with DEFAULT statement in MySQL 3.22.23b
From:       Daniel Koch <dkoch () amcity ! com>
Date:       1999-06-30 20:45:42
[Download RAW message or body]

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@homefusion.net

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/



---------------------------------------------------------------------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail mysql-thread6320@lists.mysql.com

To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail mysql-unsubscribe@lists.mysql.com instead.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic