等同于在访问中设置IDENTITY_INSERT OFF

时间:2021-04-05 09:36:14

As the title suggests, is there any way of turning off an autonumber field in Access to allow me to insert a row with an id of my choosing, such as you would do with SET IDENTITY_INSERT OFF in SQL Server?

如标题所示,是否有任何方法可以在访问中关闭autonumber字段,以允许我插入具有我选择的id的行,就像您在SQL Server中对SET IDENTITY_INSERT off所做的那样?

2 个解决方案

#1


5  

You can insert an ID with SQL.

可以使用SQL插入ID。

INSERT INTO Table1 (ID) Values (-10)

#2


2  

The autonumber property sets a field's default value as the autonumber seed value. If the autonumber field is also the primary key (or has a separate unique constraint), you can't re-use any of the stored values. However, you can explicitly insert any long integer value which doesn't conflict with the existing stored values. And without a unique constraint on the autonumber field you can insert the same value repeatedly.

自动编号属性将字段的默认值设置为自动编号种子值。如果autonumber字段也是主键(或者有单独的惟一约束),则不能重用任何存储的值。但是,可以显式地插入任何不与现有存储值冲突的长整数值。如果没有对autonumber字段的唯一约束,您可以重复地插入相同的值。

You may not really even need the equivalent of SET IDENTITY_INSERT OFF

甚至可能不需要设置IDENTITY_INSERT OFF的等效项

#1


5  

You can insert an ID with SQL.

可以使用SQL插入ID。

INSERT INTO Table1 (ID) Values (-10)

#2


2  

The autonumber property sets a field's default value as the autonumber seed value. If the autonumber field is also the primary key (or has a separate unique constraint), you can't re-use any of the stored values. However, you can explicitly insert any long integer value which doesn't conflict with the existing stored values. And without a unique constraint on the autonumber field you can insert the same value repeatedly.

自动编号属性将字段的默认值设置为自动编号种子值。如果autonumber字段也是主键(或者有单独的惟一约束),则不能重用任何存储的值。但是,可以显式地插入任何不与现有存储值冲突的长整数值。如果没有对autonumber字段的唯一约束,您可以重复地插入相同的值。

You may not really even need the equivalent of SET IDENTITY_INSERT OFF

甚至可能不需要设置IDENTITY_INSERT OFF的等效项