Best way to do multi-row insert in Oracle?

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

    In my case, I was able to use a simple insert statement to bulk insert many rows into TABLE_A using just one column from TABLE_B and getting the other data elsewhere (sequence and a hardcoded value) :

    INSERT INTO table_a (
        id,
        column_a,
        column_b
    )
        SELECT
            table_a_seq.NEXTVAL,
            b.name,
            123
        FROM
            table_b b;
    

    Result:

    ID: NAME: CODE:
    1, JOHN, 123
    2, SAM, 123
    3, JESS, 123
    

    etc

提交回复
热议问题