gpt4 book ai didi

java - 如何在 sqlite 中使用自动增量变量?

转载 作者:行者123 更新时间:2023-12-01 11:48:41 24 4
gpt4 key购买 nike

这是我在 sqlite 中的代码:stmt.execute("如果不存在人员则创建表(姓名文本,ID INTEGER PRIMARY KEY AUTOINCRMENT)");

但是当我在 Navicat 中看到我的表格并且当我想使用它时,它全部为空。我想像整数(1,2,...)一样使用它。我应该怎么办?请帮助我...

最佳答案

一个简单的谷歌查询结果如下:

摘要

The AUTOINCREMENT keyword imposes extra CPU, memory, disk space, and disk I/O overhead and should be avoided if not strictly needed. It is usually not needed.

In SQLite, a column with type INTEGER PRIMARY KEY is an alias for the ROWID (except in WITHOUT ROWID tables) which is always a 64-bit signed integer.

On an INSERT, if the ROWID or INTEGER PRIMARY KEY column is not explicitly given a value, then it will be filled automatically with an unused integer, usually the one more than the largest ROWID currently in use. This is true regardless of whether or not the AUTOINCREMENT keyword is used.

If the AUTOINCREMENT keyword appears after INTEGER PRIMARY KEY, that changes the automatic ROWID assignment algorithm to prevent the reuse of ROWIDs over the lifetime of the database. In other words, the purpose of AUTOINCREMENT is to prevent the reuse of ROWIDs from previously deleted rows.

引用: AutoIncrement SQLite

关于java - 如何在 sqlite 中使用自动增量变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28949689/

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