Multiple insert SQL oracle

后端 未结 2 1051
猫巷女王i
猫巷女王i 2020-12-06 14:20

How do you do multiple insert with SQL in Oracle 12c when you have an identity column?

INSERT ALL
INTO Table1 (Column2) Values (1)
INTO Table1 (Column2) Valu         


        
2条回答
  •  误落风尘
    2020-12-06 15:17

    Here's a workaround using the UNION ALL method instead of the INSERT ALL method. For some reason the data must be wrapped in a select * from (...) or it will generate the error ORA-01400: cannot insert NULL into ("JHELLER"."TABLE1"."TABLE1ID").

    insert into table1(column2, column3)
    select *
    from
    (
        select 'a', '1' from dual union all
        select 'b', '2' from dual
    );
    

提交回复
热议问题