I have a table that looks like this
col1 | col2
-----------
1 | a
2 | b
3 | c
and I want to run a query that makes it look like this
val | colname
-------------
1 | col1
2 | col1
3 | col1
a | col2
b | col2
c | col2
I've read about unpivot and I've figured out how to get the column names. Here's the query I am currently working with.
SELECT
*
FROM
myTable
UNPIVOT (
val
FOR
column_name
IN (
SELECT
column_name
FROM
USER_TAB_COLUMNS
WHERE
table_name = 'myTable'
)
)