我有一个TABLE1
带有 column的表COL_TAB1
。
select * from TABLE1:
COL_TAB1
| 1 |
| 2 |
| 3 |
另一个表TABLE2
包含COL_TAB2
并引用第一列COL_TAB1
select * from TABLE2:
COL_TAB2 | COL_TAB1
| val1 | 1
| val2 | 2
| val2 | 3
是否可以在 table1 上添加一个虚拟列,这样我会得到与以下查询相同的结果:
select
t1.COL_TAB1,
(select t2.COL_TAB2 from TABLE2 t2 where t2.COL_TAB1 = t1.COL_TAB1)
from TABLE1 t1
我试过了 :
alter table TABLE1 add (
SOME_COL_NAME as (select t2.COL_TAB2 from TABLE2 t2 where t2.COL_TAB1 = COL_TAB1)
)
但它给了我ORA-00936: missing expression