auto_increment 的问题 比如有一张表,ID为自增的,目前自增到了10,现在我删除ID大于5的数据,那表里面的数据只有1-5,现在继续向该表里插入数据的话,ID从10开始算起了,问题是:如何把ID从5开始算起呢,就是ID号继续是连续的,而不是删除了之后就没有这些ID号了.. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 将数据存入其它表中,删除记录,修改起始为1(ALTER TABLE dd AUTO_INCREMENT = 1),再导入数据 只有这一个办法吗,想sql server 是直接可以用set identity_insert on/OFF ,mysql没有类似的吗. alter table tbname auto_increment = 6;[ mysql不需要设置set identity_insert on tbname直接insert into tb(id,column) values(XX,XX) alter table tbname auto_increment = 6; 看来是alter table tbname auto_increment = last_ID 这个方法最好了,谢谢各位~ [email protected]_monitor>select * from test;+----+-------+| id | value |+----+-------+| 1 | 1 | | 2 | 2 | | 5 | 5 | +----+-------+3 rows in set (0.00 sec)[email protected]_monitor>delete from test where id=5;Query OK, 1 row affected (0.00 sec)[email protected]_monitor>alter table test auto_increment=3;Query OK, 2 rows affected (0.07 sec)Records: 2 Duplicates: 0 Warnings: [email protected]_monitor>insert into test(value) values(3);Query OK, 1 row affected (0.00 sec)[email protected]_monitor>select * from test;+----+-------+| id | value |+----+-------+| 1 | 1 | | 2 | 2 | | 3 | 3 | +----+-------+3 rows in set (0.00 sec)[email protected]_monitor> log-queries-not-using-indexes SQL Server 2000 DTS导出数据到MySQL 请问分区表的相关语句 请问怎样建商品表? mysql存储过程批量插入数据 MYSQL使用不了TOP是吗? 有专门管理MySQL用户权限的工具吗? ●●● ●●● ●●● linux下的mysql应用问题 windows mysql 怎么实现 多主一从 hql查询获取微博列表时如何获取是否已看过该微博,及是否赞过该微博 mysql 数据延时问题 Can't create TCP/IP socket (24)
直接
insert into tb(id,column) values(XX,XX)
alter table tbname auto_increment = 6;
+----+-------+
| id | value |
+----+-------+
| 1 | 1 |
| 2 | 2 |
| 5 | 5 |
+----+-------+
3 rows in set (0.00 sec)[email protected]_monitor>delete from test where id=5;
Query OK, 1 row affected (0.00 sec)[email protected]_monitor>alter table test auto_increment=3;
Query OK, 2 rows affected (0.07 sec)
Records: 2 Duplicates: 0 Warnings: [email protected]_monitor>insert into test(value) values(3);
Query OK, 1 row affected (0.00 sec)[email protected]_monitor>select * from test;
+----+-------+
| id | value |
+----+-------+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
+----+-------+
3 rows in set (0.00 sec)[email protected]_monitor>