赞
踩
UPDATE `table_d` SET inserttime='2020-12-15 10:41:00' WHERE 1=1;
将inserttime列全部改为固定时间
SELECT tdh_todate(sysdate,'yyyy-MM-dd HH:mm:ss') FROM SYSTEM.dual
经测试,后面必须要from某表
SELECT id,tdh_todate(sysdate,'yyyy-MM-dd HH:mm:ss') FROM `table_d`
该句返回与目标表相同条数的当前时刻,id也一一对应
最终
MERGE INTO `table_d` A USING
(SELECT id,tdh_todate(sysdate,'yyyy-MM-dd HH:mm:ss') FROM `table_d`) B ON (A.`id`=B.`id`)
WHEN MATCHED THEN UPDATE SET A.inserttime = B.`_c1`
WHEN NOT MATCHED THEN INSERT (A.id,A.name,A.inserttime) VALUES (22,'fjoerhf',B.`_c1`);
注意_c1的飘号,不然报错
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。