清空表
1.自增的id重新从1开始(如果有外键的话可能出错 使用方法2)
truncate table 你的表名
2.先清除表,然后设置自增字段从1重新开始
DELETE FROM article;
ALTER TABLE article auto_increment=1;
mybatis insert数据之后,如果设置了自增id,需要返回插入的记录id的话
<insert id="addArticle" parameterType="com.example.xxx" useGeneratedKeys="true" keyProperty="id">
插入成功之后,
lusirActicleService.addArticle(article);
int id = article.getId();//这个id就是数据表中的id,如果mapping不加上面的,返回的就是1,表示影响几条记录
replace可以代替insert,结合了insert和update的功能
因篇幅问题不能全部显示,请点此查看更多更全内容