通过 Apache Phoenix 向 table 添加一列,其默认值等于 HBase 中现有列的值

Add a column to a table with a default value equal to the value of an existing column in HBase through Apache Phoenix

我有一个 table products,其中包含 A、B 列。

我想创建一个 C 列,其值等于 B。

ALTER TABLE products ADD C DECIMAL(20,12);
UPDATE products SET C = B;

我收到一些错误 UPDATE statistics。然后我意识到 UPDATE 用于其他目的。然后我尝试如下:

ALTER TABLE products ADD C DECIMAL(20,12);
ALTER TABLE products  SET C = B;

我得到了 No rows affected,所有行的 C 仍然是 null。如何实现?

您可以使用此语句创建一个列并根据另一个列的值更新它:

ALTER TABLE products ADD C DECIMAL(20,12);
UPSERT INTO products(your_key, C) select your_key, B from products;