gpt4 book ai didi

sqlite - 在 SQLite 中设置 AUTOINCREMENT 的起始值

转载 作者:IT王子 更新时间:2023-10-29 06:17:02 35 4
gpt4 key购买 nike

如何在 SQLite 中设置 AUTOINCREMENT 字段的起始值?

最佳答案

来自SQLite web site :

SQLite keeps track of the largest ROWID that a table has ever held using the special SQLITE_SEQUENCE table. The SQLITE_SEQUENCE table is created and initialized automatically whenever a normal table that contains an AUTOINCREMENT column is created. The content of the SQLITE_SEQUENCE table can be modified using ordinary UPDATE, INSERT, and DELETE statements. But making modifications to this table will likely perturb the AUTOINCREMENT key generation algorithm. Make sure you know what you are doing before you undertake such changes.

我试过了,效果不错:

UPDATE SQLITE_SEQUENCE SET seq = <n> WHERE name = '<table>'

n+1 是您想要的下一个 ROWID,table 是表名。

关于sqlite - 在 SQLite 中设置 AUTOINCREMENT 的起始值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/692856/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com