在mysql中有一表id设为自增列(AUTO_INCREMENT)如下图:
+----+------+-----+
| id | name | sex |
+----+------+-----+
| 1 | tom | man |
| 2 | tom | man |
| 3 | tom | man |
| 5 | tom | man |
| 7 | tom | man |
| 8 | tom | man |
| 9 | tom | man |
| 10 | tom | man |
| 11 | tom | man |
+----+------+-----+
表中id不连续有间隙
如何插入新的记录,使这些新记录使用这些间隙的id值?
+----+------+-----+
| id | name | sex |
+----+------+-----+
| 1 | tom | man |
| 2 | tom | man |
| 3 | tom | man |
| 5 | tom | man |
| 7 | tom | man |
| 8 | tom | man |
| 9 | tom | man |
| 10 | tom | man |
| 11 | tom | man |
+----+------+-----+
表中id不连续有间隙
如何插入新的记录,使这些新记录使用这些间隙的id值?
解决方案 »
- 多个数据库的问题
- 高并发数据库连接问题
- 小弟初学求大神指教
- 怎样取得不同ID的前三名
- java.sql.BatchUpdateException: Lock wait timeout exceeded; try restarting transa
- mysql 中文迷糊查询
- 请教一个复杂的SQL语句
- 本人新建一数据库服务群:2681621
- TransactionTimedOutException: Transaction timed out: deadline was
- mysql怎么在非ID列排序的情况下取出某个ID之后的数据
- mysql分区表的效率以及分区表的索引问题
- My SQL安装运行不了.
谁告诉你插不进去的?只要id主键不重复就可以插入像楼主的情况,4,'tom','man' 是完全可以插入的