创建自动增长ID以及查询当前ID和下一个ID

DROP SEQUENCE PLAN.PLAN_MAINTAIN_LOG_S;

CREATE SEQUENCE PLAN.PLAN_MAINTAIN_LOG_S
  START WITH 1
  MAXVALUE 999999999
  MINVALUE 1
  NOCYCLE
  NOCACHE
  NOORDER;

<insert id="save" parameterMap="deptMap">
    		<![CDATA[
    			INSERT INTO TIME_DEPT(id,deptName,deptAddress,deptCenter,deptManager,remark,state)
    				VALUES(TIME_DEPT_LOG_S.nextval,?,?,?,?,?,?)
    		]]>
    		<selectKey resultClass="int">
    			<![CDATA[
    				SELECT TIME_DEPT_LOG_S.currval as id FROM dual
    			]]>
    		</selectKey>
    	</insert>

你可能感兴趣的:(查询)