[英]How to get mysql to auto increment starting from the previous row value
Thank you in advance for your help on this one. 提前感谢您对此的帮助。
Here's my issue: 这是我的问题:
Table A had spam accounts that I deleted. 表A包含我删除的垃圾邮件帐户。 The rows were like: 1, 2556, 2559, 2565, 2595, etc.
行如:1,2556,2559,2565,2595等。
Am trying to import Table A into the empty Table B in the same database. 我试图将表A导入到同一数据库中的空表B中。 tables have different fields.
表有不同的字段。
Table B declines the import because the insert is set to auto increment. 表B拒绝导入,因为插入设置为自动增量。 Mysql table B does not seem to want to skip rows.
Mysql表B似乎不想跳过行。
I went to Table A and updated the rows to: 我转到表A并将行更新为:
1, 2, 3,4,5..., 18 1,2,3,4,5 ......,18
Now when I try to create a user in Table A using PyphAdmin with user_id value of NULL, the id i get is 2596. Mysql still remembers the old incrementing sequence. 现在,当我尝试使用PyphAdmin创建表A中的用户,其user_id值为NULL时,我得到的id是2596.Mysql仍然记得旧的递增序列。 How can I get Mysql table to auto-increment based on the previous row so the new id will be 19 ?
如何让Mysql表基于前一行自动递增,以便新的id为19?
The mysql import file is encrypted in phpshield so I dont see what's going on and has no way to edit it. mysql导入文件在phpshield中加密,所以我不知道发生了什么,也无法编辑它。 But I assume this is what is happening after I ruled out all other possibilities.
但我认为这是在排除所有其他可能性之后发生的事情。
PRIMARY KEY (id)
PRIMARY KEY (id)
For example - 例如 -
CREATE TABLE table1(
id INT(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id)
);
Set new autoincrement value - 设置新的自动增量值 -
ALTER TABLE table1 AUTO_INCREMENT = 19
; ALTER TABLE table1 AUTO_INCREMENT = 19
;
Try this 尝试这个
ALTER TABLE A AUTO_INCREMENT=19; ALTER TABLE A AUTO_INCREMENT = 19;
ALTER TABLE
TableA
AUTO_INCREMENT = 19;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.