SQL inserts data into the table with the primary key self-increment
1. Building an Index
--Create sequence Create sequence Seq_new_old_mgeminvalue 1400maxvalue 999999999999999999999999999start with 1420increment by 1cache 20;
Note: Create sequence seq_new_old_mge, Min. 1400, Max 999999999999999999 (I don't know if it's a few 9, according to the actual random), starting from 1420, every +1, buffer 20.
2. Use Index to insert data
INSERT into New_old_mge (pk,new_id,new_name,old_id,old_name) Select Seq_new_old_mge.nextval,p.pm_num,p.pm_name, T.admin_id,t.admin_name from Basedata.ts_admin_department T left join Gdbasedata.new_old_mge n on n.old_id = T.admin _id or N.old_name = T.admin_name left joins Gdbasedata.port_mge p on p.pm_num = t.admin_id or p.pm_name = T.admin_nam e where n.new_id is null and p.pm_num are NOT null
Fix it. Where PK is the self-increasing primary key, using sequence seq_new_old_mge.nextval to increase.
SQL inserts data into the table with the primary key self-increment