Best way to do multi-row insert in Oracle?

前端 未结 9 1559
悲&欢浪女
悲&欢浪女 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:45

    If you have the values that you want to insert in another table already, then you can Insert from a select statement.

    INSERT INTO a_table (column_a, column_b) SELECT column_a, column_b FROM b_table;
    

    Otherwise, you can list a bunch of single row insert statements and submit several queries in bulk to save the time for something that works in both Oracle and MySQL.

    @Espo's solution is also a good one that will work in both Oracle and MySQL if your data isn't already in a table.

提交回复
热议问题