如何在Access中创建自动编号字段值? [英] How to create an AutoNumber field value in Access?

查看:688
本文介绍了如何在Access中创建自动编号字段值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以下操作:

CREATE TABLE Table1
(
    RecordNo autonumber, --error here!
    PersonId varchar(50),
    ...
)

但是,有一个错误.
如何在Access中建立正确的查询?

But, there is an error.
How can I build the correct query in Access?

推荐答案

根据 SQL自动增量字段:

CREATE TABLE Persons
(
P_Id PRIMARY KEY AUTOINCREMENT,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)

MS Access使用AUTOINCREMENT 关键字以执行自动递增 功能.

The MS Access uses the AUTOINCREMENT keyword to perform an auto-increment feature.

默认情况下, AUTOINCREMENT为1,它将 每条新记录增加1.

By default, the starting value for AUTOINCREMENT is 1, and it will increment by 1 for each new record.

指定"P_Id"列 应该从值10开始并递增 减5,将自动增量更改为 AUTOINCREMENT(10,5).

To specify that the "P_Id" column should start at value 10 and increment by 5, change the autoincrement to AUTOINCREMENT(10,5).

AUTOINCREMENT的同义词包括COUNTERIDENTITY.使用IDENTITY很有意义,因为它与@IDENTITY变量匹配,该变量返回最后使用的自动编号值.

Synonyms for AUTOINCREMENT include COUNTER and IDENTITY. Using IDENTITY the makes a lot of sense because it matched the @IDENTITY variable which returns the last used autonumber value.

这篇关于如何在Access中创建自动编号字段值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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