导入时 MS Access 自动编号

发布于 2024-07-22 07:32:21 字数 119 浏览 11 评论 0原文

只是好奇,当我将 519 行电子表格中的数据导入到空表中时,为什么我的自动编号键从 56,557,618 开始? 这能达到多大? 我不想最终用完我的主关键字段的数字,因为我什至没有开始该项目,并且我希望定期转储电子表格。

Just curious, when I imported data from a spreadsheet with 519 lines into an empty table, why did my autonumber keys start at 56,557,618? How big can this get? I don't want to end up running out of digits for my primary key field as I didn't even start on the project and I expect to be dumping spreadsheets in quite regularly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

等风也等你 2024-07-29 07:32:21

您可以使用以下命令重置自动编号而不进行压缩和修复:

 CurrentDb.Execute "ALTER TABLE tblTable ALTER COLUMN ID COUNTER(1,1)"

您必须在运行 SQL 之前确保表为空,否则 Access 将尝试创建重复的自动编号。

You can reset the autonumber without compact and repair using :

 CurrentDb.Execute "ALTER TABLE tblTable ALTER COLUMN ID COUNTER(1,1)"

You must make sure the table is empty before running the SQL or you will get Access trying to create duplicate autonumbers.

独留℉清风醉 2024-07-29 07:32:21

即使在空表上,Access 也会记住它给出的最后一个 ID。 要重置自动编号,您必须在清空表后压缩/修复数据库

此外,自动编号是一个长整数,在 Access 中最多可达 2,147,483,647

Access remembers the last ID it gave out even on an empty table. To reset the autonumber you have to compact/repair the database after emptying the table

Also the autonumber is a long integer which in Access can go up to 2,147,483,647

末が日狂欢 2024-07-29 07:32:21

您还可以通过创建包含自动编号列的追加查询来重置自动编号。 追加一行后,数字将设置为追加的值 + 1。

执行此操作时,您必须小心该值不小于当前的最高值。

例如

INSERT INTO tblName ( id )
SELECT [tblName]![id]+1 AS [New Value]
FROM tblName
GROUP BY [tblName]![id]+1, tblName.id
HAVING (((tblName.id)=(Select max(id) from tblName)));

将自动编号重置为最后一个数字的 + 2。 请注意,您必须包含所有必填列,然后删除新行。

You can also reset the autonumber by creating an append query that includes the autonumber column. Once a row is appended then the number will be set to the appended value + 1.

Doing this you have to be careful that the value is not less than the highest current value.

For e.g.

INSERT INTO tblName ( id )
SELECT [tblName]![id]+1 AS [New Value]
FROM tblName
GROUP BY [tblName]![id]+1, tblName.id
HAVING (((tblName.id)=(Select max(id) from tblName)));

Would reset the autonumber to + 2 of the last number. Note you would have to include any mandatory columns and delete the new row afterwards.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文