# [EMAIL PROTECTED] / 2003-06-25 07:10:46 +0100:
> Sometime recently Roman Neuhauser said:
> > # [EMAIL PROTECTED] / 2003-06-25 06:18:04 +0100:
> > > 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)
>
> You're right, just tested it myself on 3.23.41; and I get exactly
> the same result as you. We should post an amendment to the docs
> on the website.
>
> However, (still with 3.23.41):
>
> mysql> create table autotime2 (foo int, bar timestamp default now());
> ERROR 1064: You have an error in your SQL syntax near 'now())' at line 1
> mysql> create table autotime2 (foo int, bar timestamp default 'now()');
> Query OK, 0 rows affected (0.00 sec)
>
> mysql> insert autotime2 set foo = 2;
> Query OK, 1 row affected (0.00 sec)
>
> mysql> insert autotime2 set foo = 1;
> Query OK, 1 row affected (0.00 sec)
>
> mysql> select * from autotime2;
> +------+----------------+
> | foo | bar |
> +------+----------------+
> | 2 | 20030625102215 |
> | 1 | 20030625102222 |
> +------+----------------+
> 2 rows in set (0.00 sec)
mysql> create table dt (foo int, bar datetime default 'now()');
Query OK, 0 rows affected (0.00 sec)
mysql> create table ts (foo int, bar timestamp default 'now()');
Query OK, 0 rows affected (0.02 sec)
mysql> desc dt;
+-------+----------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------------------+-------+
| foo | int(11) | YES | | NULL | |
| bar | datetime | YES | | 0000-00-00 00:00:00 | |
+-------+----------+------+-----+---------------------+-------+
2 rows in set (0.02 sec)
mysql> desc ts;
+-------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------+------+-----+---------+-------+
| foo | int(11) | YES | | NULL | |
| bar | timestamp(14) | YES | | NULL | |
+-------+---------------+------+-----+---------+-------+
2 rows 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]