简体   繁体   中英

Insert multiple rows with multiple values nextval Oracle SQL

I'm trying to insert 2 rows with several values and test_id.nextval into an existing dataframe without including the column headings in the code:

insert into x
    select * from
        (select 12345, 'text', test_id_seq.nextval from dual
    union all
        select 23589, 'other text', test_id_seq.nextval from dual);

I got the error: sequence number not allowed here . So I removed the sequence number. Then the error not enough values occured. How can I insert multiple rows into an existing table with nextval ids?

Try this:

    insert into x
    select tt.* , test_id_seq.nextval from
    (select 12345, 'text' from dual
    union all
    select 23589, 'other text' from dual) tt;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM