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

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


字段配置为:

  `pollTs` timestamp NULL DEFAULT CURRENT_TIMESTAMP,


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

我的MySQL是5.5.28

谢谢

仅通过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和一个字符串时,会发生这种情况。

最佳答案

它为我工作

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)

关于mysql - MySQL-更新时间戳from_unixtime删除行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21456469/

10-10 17:43
查看更多