我有一张像这样的桌子:
column1 column2 column3 column4 A B C D
想要将其转换为:
Column A B C D
在oracle中不使用此联合:
select column1 as Column from dual union all select column2 as Column from dual union all select column3 as Column from dual union all select column4 as Column from dual
您可以尝试使用unpivot
select v from ( SELECT 'A' column1,'B' column2,'C' column3,'D' column4 from dual ) t unpivot ( v for val in (column1,column2,column3,column4) ) u;
sqlfiddle:https ://dbfiddle.uk/ ? rdbms = oracle_11.2 & fiddle = b2105e1010b332ce5b702eba7bfa7f2d