Insert 3 columns in 1 columns SQL [closed]

A generic approach uses insert ... select and union all:

insert into newtable (value)
select column01 from oldtable
union all select column02 from oldtable
union all select column03 from oldtable

In Oracle, this is more efficiently done with cross apply, so the table is scanned only once instead of three times:

insert into newtable (value)
select v.col 
from oldtable o
cross apply (
    select o.column01 col from dual
    union all select o.column02 from dual
    union all select o.column03 from dual
) v

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top