我有一个 stats
桌
name | age | sound
------------------
m | 5 | a
a | 3 | c
c | 5 | d
f | 1 | j
d | 6 | r
c | 55 | d
我添加了一列名为 appearance
ALTER TABLE stats
ADD appearance INTEGER DEFAULT case
when age > 4 then 'red'
when name = f then 'blue'
end
并得到一个这样的表。
name | age | sound | appearance
--------------------------------
m | 5 | a | red
a | 3 | c | <null>
c | 5 | d | red
f | 1 | j | blue
d | 6 | r | red
c | 55 | d | red
然后,我想再增加一列,叫做 flavor
ALTER TABLE stats
ADD flavor varchar(20) case
WHEN appearance = 'red' THEN 'apple'
WHEN appearance = 'blue' THEN 'blueberry'
END
但我一直收到错误信息。
[Vertica][VJDBC](7344) ROLLBACK: default expressions may not refer to other columns with default expressions
如何从我创建的第一列创建第二列?