我有这个 3k 的数据需要更新,但问题是列类型是布尔值。 所以我试图将数据随机化为"真"或"假",因为现在的列值都是"真"。 下面是我的代码:
UPDATE dashboard.availability
SET in_opt_hrs = (array['true', 'false'])[(random() * 0 + 1)::int];
我尝试使用上面的代码,但 postgresql 抛出一个错误:column "in_opt_hrs" is of type boolean but expression is of type text
有什么办法可以解决这个问题吗?
只使用布尔表达式怎么样?
update dashboard.availability
set in_opt_hrs = (random() < 0.5);
这是一个数据库<>小提琴。