将数据复制到oracle中的另一个桥表中

时间:2016-06-18 17:06:58

标签: oracle

我想将表主题,参考,教学大纲中的主键复制到表Reference_Subject中。这不起作用:

INSERT INTO REFERENCE_SUBJECT (REFERENCE_ID,SYLLABUS_ID,SUBJECT_ID)
(SELECT REFERENCE_ID FROM REFERENCE
 , SELECT SYLLABUS_ID FROM SYLLABUS
 , SELECT SUBJECT_ID FROM SUBJECT);

错误是

  

表名无效

2 个答案:

答案 0 :(得分:0)

我真的认为你需要加入REFERENCE, SYLLABUS, SUBJECT

INSERT INTO REFERENCE_SUBJECT 
(REFERENCE_ID,SYLLABUS_ID,SUBJECT_ID)
SELECT REFERENCE_ID ,SYLLABUS_ID, SUBJECT_ID  
  FROM REFERENCE,  SYLLABUS, SUBJECT;

答案 1 :(得分:0)

使用select distinct,否则你获得重复的行做连接表格REFERENCE,SYLLABUS,SUBJECT

无论如何你还要加入3张桌子......不知道加入你可以

INSERT INTO REFERENCE_SUBJECT (REFERENCE_ID,SYLLABUS_ID,SUBJECT_ID)
SELECT DISTINCT REFERENCE_ID  SYLLABUS_ID SUBJECT_ID 
FROM REFERENCE, SYLLABUS, SUBJECT;