如何获得下一个AutoIncrement值 [英] How to Get Next AutoIncrement Value

查看:106
本文介绍了如何获得下一个AutoIncrement值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



有没有办法从VFP表中获取下一个AutoIncrement值?因为如果我从最后/最大值中删除任何记录,它不能是最大值。



最好的问候

ShahidSQL(印度)

Dear All,

Is there any way to get next AutoIncrement value from VFP table? Because it can't be max value if I have deleted any record from last/max value.

Best Regards
ShahidSQL (India)

推荐答案

表设计者知道它存储在标题中。但是在添加下一条记录之前没有用于获取它的用例。

The table designer knows it as it's stored in the header. But there is no use case for getting at it before adding the next record.

删除记录时它不会减少,删除的记录不会被删除,只是标记为已删除,因此对于主键索引,您仍然无法重用该数字。它总是只增加。没有必要摆弄它。由于许多原因,减少它是错误的
,例如当你没有级联删除详细记录并重复使用数字时,删除的标题的详细数据突然变成新的子数据记录它不属于。

When you delete a record it won't decrement, the deleted record is not deleted, just marked deleted and so for a primary key index, you still can't reuse that number. It always only increments. There's no need to fiddle with it.Decreasing it is wrong for many reasons, eg when you don't have cascading delete of detail records and reuse a number, detail data of a deleted header suddenly becomes child data of a new record it doesn't belong to.

如果要在使用APPEND导入一些数据后对齐自动增量计数器,则必须使用ALTER TABLE重置它,但这不适用于通常的业务删除单个记录。

If you want to align the autoincrement counter after importing some data with APPEND you have to use ALTER TABLE to reset it, but that's not for the usual business of deleting single records.

再见,奥拉夫。


这篇关于如何获得下一个AutoIncrement值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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