如果我从数据库中的表中删除一行如何重命名主键
问题描述:
所以我想从表格中删除一行,例如
So I want to delete a row from a table e.g
1
2
3
4
5
7
8
如何重命名表行主键,使它们等于
How do I rename the tables rows primary keys so they are equal to
1
2
3
4
5
6
7
答
这个问题经常出现,但它是一个错误的问题.你不必关心 id.它只是一个标识符.保持原状.
This question comes frequently but it's a false problem. You don't have to care about id. It's just an identifier. Leave it as it is.
您可以使用您喜欢的编程语言或通过 sql 以编程方式添加累进数.
You can add a progressive number programmatically, using your favourite programming language or via sql.
select *,@row:=@row+1 as progressive_number
from table, (select @row:=0) as t