sql - How to insert data to table from differences between this table and other one, using genereted sequence id? -


i have 2 tables , try insert rows second_table first_table.

i create 2 tables:

create table first_table(     f_id number(10) not null,     f_name varchar(8 byte) not null,     f_description nvarchar2(1000) not null   );     create table second_table(     s_id number(10) not null,     s_name varchar(8 byte) not null,     s_description nvarchar2(1000) not null   ); 

i found differences between second_table , first_table:

select s_name,s_description second_table minus select f_name,f_description first_table;

i create statement:

insert first_table f_id,f_name,f_description (select * second_table not exists (select * first_table second_table.s_name = first_table.f_name));

but statement copy f_id, don't have idea how change statement not copy f_id, generate sequence css_f. should looks like:

insert first_table (f_id) values (css_f.nextval);

could give me advice how add inserting genereted id statement?

you can select name , description columns second_table , use sequence inserting f_id column.

insert first_table (f_id,f_name,f_description) select css_f.nextval, s_name, s_description second_table s not exists (select * first_table s.s_name = f_name) 

Comments