I have a legacy table whos data I have to migrate to a new structure. In the old structure each row represesnts an year, having fields for each month. In the new one each row will represent a month. The old structure is :
OLD_TABLE (
id1,
id2,
year,
price01,
price02,
price03,
price04,
...
price11,
price12,
quantity01,
quantity02,
quantity03,
...
quantity11,
quantity12,
) -> PK = id1,id2,year
the new structure is like this :
NEW_TABLE (
id1,
id2,
year,
month,
quantity,
price,
) -> PK = id1,id2, year
Any advices on how should i proceed in migrating data from the old structure to the new one?
Thank you!
If you are using 11g or later, look at the
unpivotsyntaxSomething like…