© Kim Berg Hansen 2020
K. Berg HansenPractical Oracle SQLhttps://doi.org/10.1007/978-1-4842-5617-6_7

7. Unpivoting Columns to Rows

Kim Berg Hansen1 
(1)
Middelfart, Denmark
 

Ideally, you’d hope always to work with data that’s nicely normalized in your relational database, the way they teach in computer science classes. In reality it’s quite often not as ideal.

One quite common pattern is to have some data with a bunch of columns, where you’d really like those data as rows with, for example, key-value pairs, where the key would be derived from the original column name and the value then would be the value from that column.

Personally I like to use the terms dimension and measure instead of key and value. You might say that’s only for data warehousing ...

Get Practical Oracle SQL: Mastering the Full Power of Oracle Database now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.