当前位置:Gxlcms > 数据库问题 > postgresql实现插入数据返回当前的主键ID

postgresql实现插入数据返回当前的主键ID

时间:2021-07-01 10:21:17 帮助过:6人阅读

insert id="addUser" parameterType="com.liupan.user"> <selectKey keyProperty="id" resultType="java.lang.Integer" order="AFTER"> select currval(‘user_user_id_seq‘) as id </selectKey> insert into USER(USER_NAME,PASSWORD,CREATE_TIME) values(#{userId},#{password},#{createTime,typeHandler=dateTimeTypeHandler}) </insert>

除了currval()函数外,还有nextval()函数,但是nextval()函数会导致postgresql的主键加1,所以不能用在这种情况下

postgresql实现插入数据返回当前的主键ID

标签:result   pos   pass   主键   插入   res   div   ram   sql   

人气教程排行