2. Create a sequence
--Create sequence
Create sequence Seq_ship_image
MinValue 20
MaxValue 999999999999999999
Start with 40
Increment by 1
Cache 20;
Use sequence:
SELECT Seq_ship_image. Nextval from dual;
Insert into Ship_image (id,img_path,remark,ship_id) VALUES (seq_ship_image. Nextval, ' ship3.jpg ', ' 8 ', ' 8 ');
Or
<!--corresponds to Insertuser method in Userdao,-- <insert id= "Insertuser" parametertype= "Com.dy.entity.User" > <!--Oracle, etc. does not support ID self-growth, can be generated according to its ID policy, first get the ID <selectkey resulttype= "int" order= "before" keyproperty= "id" > select Seq_user_id.nextval as ID from dual </selectKey>-- insert INTO user (ID, name, Password, age, Deleteflag) values (#{id}, #{name}, #{password}, #{age}, #{deleteflag}) </insert>
Oracle database build sequence, use sequence to implement primary key self-increment