我想通过将date类型的行更改为timestamp类型的行来更改sql中的表。我想使用date类型的旧值,并将它们复制到timestamp类型的新行。此外,我希望将时间戳与时间"12:00“(中午)连接起来。
我的尝试:
-- Create a temporary TIMESTAMP column
ALTER TABLE guest_group ADD COLUMN create_time_holder TIMESTAMP without time zone NULL;
-- Copy casted value over to the temporary column and set time to 12:00
UPDATE guest_group SET create_time_holder = arrival_date::TIMESTAMP without time zone AS "12:00";
结果应该是一个包含旧日期的值(时间戳),字符串为"12:00“
2019-12-20 12:00
发布于 2019-06-08 22:28:56
如果你使用的是Postgres,我认为这是你想要的:
UPDATE guest_group
SET create_time_holder = arrival_date::date + interval '12 hour';
https://stackoverflow.com/questions/56507268
复制相似问题