Oracle之行列转置

前端之家收集整理的这篇文章主要介绍了Oracle之行列转置前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

创建两张测试表
@H_301_2@

sql>createtablet1as
2select'one'asd1,3'two'asd2,4'three'asd3,5'four'asd4,6'five'asd5fromdual;

sql>createtablet2(dvarchar2(10),desvarchar2(50);

转置@H_301_2@

sql>insertall
2intot2(d,des)values('一',d1)
3intot2(d,des)values('二',d2)
4intot2(d,des)values('三',d3)
5intot2(d,des)values('四',d4)
6intot2(d,des)values('五',d5)
7selectd1,d2,d3,d4,d5fromt1;

类似@H_301_2@

sql>insertintot2(d,des)
2select'一',d1fromt1unionall
3select'二',d2fromt1unionall
4select'三',d3fromt1unionall
5select'四',d4fromt1unionall
6select'五',d5fromt1;
原文链接:https://www.f2er.com/oracle/209107.html

猜你在找的Oracle相关文章