ORA-00913 too many values

后端 未结 2 855
傲寒
傲寒 2021-01-28 12:37

I have this query

INSERT INTO hist_museum (SELECT * from of_owner.museum al
                                JOIN (SELECT vd.city_data_id 
                                


        
2条回答
  •  盖世英雄少女心
    2021-01-28 13:01

    The best-practice when doing an insert is to list the columns explicitly:

    INSERT INTO hist_museum(col1, col2, . . . )
         SELECT col1, col2, . . .
         FROM of_owner.museum al JOIN
              of_owner.city_data vd 
              ON al.city_data_id = VD.city_data_id
         WHERE gps_full_date < add_months(SYSDATE, -12);
    

    Of course, the columns in the SELECT, should be qualified with the table name.

    In addition, the subquery is unnecessary. There is no reason to write a subquery just to filer data.

提交回复
热议问题