RE: Defaul of NOW()

2004-05-27 Thread Victor Pendleton
Only constant values are allowed as default values. If this is the first
timestamp column it will be updated on insert and with every update.

-Original Message-
From: Scott Haneda
To: MySql
Sent: 5/26/04 8:20 PM
Subject: Defaul of NOW()

I have a field in mysql 4, using InnoDB
Field is timestamp 14 and defualt is set to 00, which I want
to
be the result of NOW() so that every record made will get NOW() as the
value, I can not get it to work...

ALTER TABLE `addresses` CHANGE `added` `added` TIMESTAMP( 14 ) DEFAULT
'NOW()';
Query OK, 2 rows affected (0.01 sec)
Records: 2  Duplicates: 0  Warnings: 0


It tells me it worked, but then it reverts back to the zero's.
-- 
-
Scott HanedaTel: 415.898.2602
http://www.newgeo.com   Fax: 313.557.5052
[EMAIL PROTECTED]Novato, CA U.S.A.



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

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



Re: Defaul of NOW()

2004-05-27 Thread Scott Plumlee
I didn't think you could have a DEFAULT of NOW() because it's not a true 
static value.  Seems I read that in one of Paul DuBois' books.

Jim Winstead wrote:
On Wed, May 26, 2004 at 06:20:22PM -0700, Scott Haneda wrote:
I have a field in mysql 4, using InnoDB
Field is timestamp 14 and defualt is set to 00, which I want to
be the result of NOW() so that every record made will get NOW() as the
value, I can not get it to work...
ALTER TABLE `addresses` CHANGE `added` `added` TIMESTAMP( 14 ) DEFAULT
'NOW()';
Query OK, 2 rows affected (0.01 sec)
Records: 2  Duplicates: 0  Warnings: 0
It tells me it worked, but then it reverts back to the zero's.

If you do a SHOW CREATE TABLE on the table, you'll see that it has
actually ignored your DEFAULT. (What is has done is actually transformed
it to '00', since that is what the string 'NOW()' becomes
when you convert it to a TIMESTAMP.)
Read this section in the manual for information on how the default value
for TIMESTAMP columns is handled:
  http://dev.mysql.com/doc/mysql/en/TIMESTAMP_pre-4.1.html
Support for specifying how TIMESTAMP columns get updated is coming in
4.1.2. Right now, it is only documented in the change notes:
  http://dev.mysql.com/doc/mysql/en/News-4.1.2.html
Jim Winstead
MySQL AB

--
Scott Plumlee
PGP Public key: http://plumlee.org/pgp/   D64C 47D9 B855 5829 D22A  D390 
F8E2 9B58 9CBF 1F8D

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


Re: Defaul of NOW()

2004-05-26 Thread Jim Winstead
On Wed, May 26, 2004 at 06:20:22PM -0700, Scott Haneda wrote:
 I have a field in mysql 4, using InnoDB
 Field is timestamp 14 and defualt is set to 00, which I want to
 be the result of NOW() so that every record made will get NOW() as the
 value, I can not get it to work...
 
 ALTER TABLE `addresses` CHANGE `added` `added` TIMESTAMP( 14 ) DEFAULT
 'NOW()';
 Query OK, 2 rows affected (0.01 sec)
 Records: 2  Duplicates: 0  Warnings: 0
 
 It tells me it worked, but then it reverts back to the zero's.

If you do a SHOW CREATE TABLE on the table, you'll see that it has
actually ignored your DEFAULT. (What is has done is actually transformed
it to '00', since that is what the string 'NOW()' becomes
when you convert it to a TIMESTAMP.)

Read this section in the manual for information on how the default value
for TIMESTAMP columns is handled:

  http://dev.mysql.com/doc/mysql/en/TIMESTAMP_pre-4.1.html

Support for specifying how TIMESTAMP columns get updated is coming in
4.1.2. Right now, it is only documented in the change notes:

  http://dev.mysql.com/doc/mysql/en/News-4.1.2.html

Jim Winstead
MySQL AB

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