Oracle 11g provides new row and column conversion operations: Convert (row to column) and unconvert column to row. This document describes the unregister function.
The existing table src_table is as follows:
Product_Id (product ID) |
Product_color (color) |
Porduct_type (model) |
Is_intelligent (smart or not) |
1111 |
Red |
T1 |
Yes |
1112 |
Blue |
T2 |
No |
1113 |
Green |
T3 |
Yes |
The target table dest_table is as follows:
Product_Id |
Param_name (parameter name) |
Param_value (parameter value) |
1111 |
Product_color |
Red |
1112 |
Product _Color |
Blue |
1113 |
Product _Color |
Green |
1111 |
Product _Type |
T1 |
1112 |
Product _Type |
T2 |
1113 |
Product_tYpe |
T3 |
1111 |
Is_intelligent |
Yes |
1112 |
Is_intelligent |
No |
1113 |
Is_intelligent |
Yes |
Unregister is implemented as follows:
SELECT *
FROM src_table
Unordered (param_value FOR param_name IN (product_color AS 'product _ color', product_type AS 'product _ type', is_intelligent AS 'is _ intelligent ');