如何再次从1开始更新id列 [英] How to update the id column starting from 1 again

查看:78
本文介绍了如何再次从1开始更新id列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从1,2,3,4,5开始再次更新ID号列表时遇到问题.由于我在测试sql命令时已删除了几条记录.您能帮忙从1开始重新制作此id列吗?

I am having problem to update the list of id number again starting from 1,2,3,4,5. Since I have deleted few records as I was testing the sql commands. Can you please help on how to make this id column again starting from 1.

我可以输入ID号的名称,但是如果这样做,那么当我输入新记录时,它将再次从上一个数字66开始.

I could just the name of the id number however if I do that then when I input new record, it will again start from the previous number which was 66.

ID    Name 

1   A

32  B

34  C

35  D

55  E

66  F

推荐答案

最简单(有时最快)的方法是删除列并将其重新添加.更新列可能会破坏索引或使值混乱.丢掉整个桌子毫无意义.但是请记住,如果其他列引用了这些ID,则可能会损坏您的应用.

The easiest (and sometimest fastest) way is to remove column and add it back. Updating column may screw up indexes or make a mess with values. Droping whole table got no sense. But remember that if other columns refer to that ids you can damage your app.

这篇关于如何再次从1开始更新id列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆