a(ID1, name,sex) b(ID2,ID1,Fraction) ID1,ID2 同为自动增长 ID1 为b表的外键参照a表的ID1
1、先创建a和b表的序列 CREATE SEQUENCE SEQ_A; CREATE SEQUENCE SEQ_B; 2、插入A表并返回A表当前ID v_id1 number(20); insert into a (ID1,name,sex)values(SEQ_A.NEXTVAL,name_value,sex_value)
return ID1 into v_id1; 3、插入B表 insert into b (ID2,ID1,Fraction)values(SEQ_B.NEXTVAL,v_id1,franction_value); 4、事务提交 commit;
标签:往主外,SEQ,键表中,into,value,ID1,oracle,sex,id1 From: https://blog.51cto.com/u_2198048/6196317