我有一张桌子:
-----------------------
Name | Age | Gender |
-----------------------
abc | 22 | m |
pqr | 26 | m |
xyz | 33 | f |
-----------------------
我希望将其插入另一个表中:
Value Variable
name abc
age 22
gender m
name pqr
age 26
gender m
name xyz
age 33
gender f
如何在PL / SQL中执行此操作? 如果我的表包含数百万条记录,我该怎么做呢?
答案 0 :(得分:0)
insert into other_table (value, variables)
select 'name', name from your_table
union all
select 'age', age from your_table
union all
select 'gender', gender from your_table
答案 1 :(得分:0)
你不需要PL / SQL。只是:
insert all
into other_table (thing_name, thing_value) values ('name', name)
into other_table (thing_name, thing_value) values ('age', age)
into other_table (thing_name, thing_value) values ('gender', gender)
select name, age, gender from some_table;