17. View the Exhibit and examine the structure of the MARKS_DETAILS and MARKS
tables.Which is the best method to load data from the MARKS_DETAILS table
to the MARKS table?
A. Pivoting INSERT
B. Unconditional INSERT
C. Conditional ALL INSERT
D. onditional FIRST INSERT
Answer: A
create table MARKS_DETAILS
(
student_id NUMBER(4),
subject_id NUMBER(2),
marks_english NUMBER,
s1 NUMBER,
marks_math NUMBER,
s2 NUMBER,
marks_physics NUMBER,
s3 NUMBER,
marks_chemistry NUMBER,
s4 NUMBER
marks_biology NUMBER,
);
insert into MARKS_DETAILS values(10,1,100,2,120,3,90,4,110,5,88);
create table MARKS
(
student_id NUMBER(4),
subject_id NUMBER(2),
marks NUMBER
);
insert all
into marks values(student_id,subject_id,marks_english)
into marks values(student_id,s1,marks_math)
into marks values(student_id,s2,marks_physics)
into marks values(student_id,s3,marks_chemistry)
into marks values(student_id,s4,marks_biology)
select student_id,subject_id,s1,s2,s3,s4,marks_english,marks_math,
marks_physics,marks_chemistry,marks_biology
from marks_details;
eg2:
某表含有
表头 ID , 年,1月预算,2月预算,3月预算
表值 col1,2012年, a, b, c
这样的5个字段,
我想转成
col1,2012年,1月, a
col1,2012年,2月, b
col1,2012年,3月, c
需要转换的表:test
insert all
into target_test values(id,year,'1月',month1)
into target_test values(id,year,'2月',month2)
into target_test values(id,year,'3月',month3)
select id,year,month1,month2, month3 from test;