Mysql - 更新时间戳from_unixtime删除该行

时间:2014-01-30 12:24:21

标签: mysql perl

如果我运行以下SQL,该行将消失:

update t set
ts = from_unixtime(13933210)
where id = 3978947

字段配置为:

  `pollTs` timestamp NULL DEFAULT CURRENT_TIMESTAMP,

我尝试删除索引,但结果仍然相同。

我的MySQL是5.5.28

由于

update 仅通过PERL DBI DBD MYSQL客户端

发生
my $id =  $dbh->last_insert_id( undef, undef, undef, undef );
my $sql = "update nodePerf set
            ts = ?
            where id = $id";

my $sth = $dbh->prepare($sql);
$sth->execute($ts);

当from_unixtime和字符串时会发生这种情况。

1 个答案:

答案 0 :(得分:0)

它为我工作

create table t(date_entered timestamp NULL DEFAULT CURRENT_TIMESTAMP);
Query OK, 0 rows affected (0.24 sec)

SELECT * FROM t;
Empty set (0.00 sec)

INSERT INTO t VALUES();
Query OK, 1 row affected (0.00 sec)

SELECT * FROM t;
+---------------------+
| date_entered        |
+---------------------+
| 2014-01-30 17:55:56 |
+---------------------+
1 row in set (0.00 sec)

UPDATE t SET date_entered = from_unixtime(13933210) ;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

SELECT * FROM t;
+---------------------+
| date_entered        |
+---------------------+
| 1970-06-11 11:50:10 |
+---------------------+
1 row in set (0.00 sec)