有時候須要修改序列初始值,有如下幾種方法:數據庫
CREATE SEQUENCE [ schema. ]sequence
[ { INCREMENT BY | START WITH } integer
| { MAXVALUE integer | NOMAXVALUE }
| { MINVALUE integer | NOMINVALUE }
| { CYCLE | NOCYCLE }
| { CACHE integer | NOCACHE }
| { ORDER | NOORDER }
];緩存
ALTER SEQUENCE [ schema. ]sequence
{ INCREMENT BY integer
| { MAXVALUE integer | NOMAXVALUE }
| { MINVALUE integer | NOMINVALUE }
| { CYCLE | NOCYCLE }
| { CACHE integer | NOCACHE }
| { ORDER | NOORDER }
};oracle
<insert id="insert" parameterType="com.test.domain.Student"
useGeneratedKeys="true" keyProperty="Id">
<selectKey resultType="int" order="BEFORE" keyProperty="Id">
select SEQ_STUDENT_ID.nextval from dual
</selectKey>
insert into student
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id!= null">
ID,
</if>
<if test="name!= null">
NAME,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="name != null">
#{name,jdbcType=INTEGER},
</if>
</trim>
</insert>dom