gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 00:44:56 33 4
gpt4 key购买 nike

如果我运行以下 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 - 更新时间戳 from_unixtime 删除该行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21456469/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com