# [EMAIL PROTECTED] / 2003-06-25 06:18:04 +0100:
> Sometime recently MaFai said:
> >     A table contains a column named "mydate".
> >     
> >     //Wrong sql statement
> >     alter table p_asset add mydate datetime default now();
> >     alter table p_asset add mydate datetime default time();
> >     alter table p_asset add mydate datetime default now;
> >     alter table p_asset add mydate datetime default time;
> >     alter table p_asset add mydate datetime default date();
> >     alter table p_asset add mydate datetime default datetime();
> > 
> >     How can I add the default now value into the specified column?
> >     I try to find in the mysql manual,but in the default value charter,no relative 
> > information can be found.
> >     
> >    I also know this question is stupid,but hope you help.
> 
> alter table p_asset add mydate datetime default 'now()';
> 
>  - you need the '' around now(); apparently
> 
> http://www.mysql.com/doc/en/DATETIME.html
> and scroll down to the comment made by 
> Lazy Soul on Tuesday May 27 2003, @8:15am

    I'd like to know in which version of MySQL this does what it's
    intended to do. Definitely not in 4.0.13:

    mysql> create table autotime (foo int, bar datetime default 'now()');
    Query OK, 0 rows affected (0.00 sec)

    mysql> insert autotime set foo = 1;
    Query OK, 1 row affected (0.06 sec)

    mysql> insert autotime set foo = 2;
    Query OK, 1 row affected (0.00 sec)

    mysql> select * from autotime;
    +------+---------------------+
    | foo  | bar                 |
    +------+---------------------+
    |    1 | 0000-00-00 00:00:00 |
    |    2 | 0000-00-00 00:00:00 |
    +------+---------------------+
    2 rows in set (0.02 sec)

    mysql> select version();
    +------------+
    | version()  |
    +------------+
    | 4.0.13-log |
    +------------+
    1 row in set (0.00 sec)


-- 
If you cc me or remove the list(s) completely I'll most likely ignore
your message.    see http://www.eyrie.org./~eagle/faqs/questions.html

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to