Best way to do multi-row insert in Oracle?

前端 未结 9 1419
悲&欢浪女
悲&欢浪女 2020-11-22 02:52

I\'m looking for a good way to perform multi-row inserts into an Oracle 9 database. The following works in MySQL but doesn\'t seem to be supported in Oracle.



        
9条回答
  •  遥遥无期
    2020-11-22 03:35

    In Oracle, to insert multiple rows into table t with columns col1, col2 and col3 you can use the following syntax:

    INSERT ALL
       INTO t (col1, col2, col3) VALUES ('val1_1', 'val1_2', 'val1_3')
       INTO t (col1, col2, col3) VALUES ('val2_1', 'val2_2', 'val2_3')
       INTO t (col1, col2, col3) VALUES ('val3_1', 'val3_2', 'val3_3')
       .
       .
       .
    SELECT 1 FROM DUAL;
    

提交回复
热议问题