Hi Leandro,

It is absolutly correct. Please read in doc about timestamp data type
http://www.mysql.com/doc/en/DATETIME.html

************************
The TIMESTAMP column type provides a type that you can use to automatically
mark INSERT or UPDATE operations with the current date and time. If you have
multiple TIMESTAMP columns, only the first one is updated automatically.

Automatic updating of the first TIMESTAMP column occurs under any of the
following conditions:

  a.. The column is not specified explicitly in an INSERT or LOAD DATA
INFILE statement.
  b.. The column is not specified explicitly in an UPDATE statement and some
other column changes value. (Note that an UPDATE that sets a column to the
value it already has will not cause the TIMESTAMP column to be updated,
because if you set a column to its current value, MySQL ignores the update
for efficiency.)
  c.. You explicitly set the TIMESTAMP column to NULL.
TIMESTAMP columns other than the first may also be set to the current date
and time. Just set the column to NULL or to NOW().

You can set any TIMESTAMP column to a value different from the current date
and time by setting it explicitly to the desired value. This is true even
for the first TIMESTAMP column. You can use this property if, for example,
you want a TIMESTAMP to be set to the current date and time when you create
a row, but not to be changed whenever the row is updated later:

  a.. Let MySQL set the column when the row is created. This will initialize
it to the current date and time.
  b.. When you perform subsequent updates to other columns in the row, set
the TIMESTAMP column explicitly to its current value.
On the other hand, you may find it just as easy to use a DATETIME column
that you initialize to NOW() when the row is created and leave alone for
subsequent updates.

************************

Best regards,
Mikhail.


----- Original Message ----- 
From: "Leandro Saggin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 07, 2004 2:12 PM
Subject: Timestamp Problems


Hello,

I am having problems with columns timestamp, what it happens is the
following:

I created the following table using timestamp and inserted data in this
table:

create table con(cod integer not null primary key auto_increment, cod_access
integer, hr_con timestamp(14), hr_descon timestamp(14), status char);
insert into con values(null,1,'20040107120000','20040107120030','D');

when executing select in the table, the data are correct

select * from con;
+------------------------+-----------------------+-------------------------+
--------------------------+----------+
 | cod                   | cod_access      | hr_con               |
hr_descon           | status |
+-------------------------+----------------------+-------------------------+
--------------------------+----------+
 |                       1 |                     1 | 20040107120000 |
20040107120030  | D       |
+-------------------------+----------------------+--------------------------
+--------------------------+---------+
1 row in set (0.01 sec)

then I make one update in the column hr_descon

update con set hr_descon='20040107120100';

there it is the problem, when bringing up to date the column hr_descon for
the value informed in update, the column hr_con is brought up to date
automatically for current date/time

select * from con;
select * from con;
+------------------------+-----------------------+-------------------------+
--------------------------+----------+
 | cod                   | cod_access      | hr_con               |
hr_descon           | status |
+-------------------------+----------------------+-------------------------+
--------------------------+----------+
 |                       1 |                     1 | 20040107101056 |
20040107120100 | D        |
+-------------------------+----------------------+--------------------------
+--------------------------+---------+
1 row in set (0.01 sec)

I am using Operational System Solaris 9 on Sparc Platform and I tested in
versions 3.23.47, 3.23.58 and 4.0.14 of mysql. If somebody to know what
happens please helps I.

Thanks!!!


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

Reply via email to