Recently, you need to remove the primary key from a table in the ACCESS database in the program and then perform some operations. Then add the primary key. You can use this SQL statement to complete
Remove primary key
Alter table Table Name drop constraint primarykey
The above primarykey is the name of the Integrity Constraint, And the ACCESS database uses the default name primarykey for the primary key constraint. Of course, if the primary key constraint is named by another user, the corresponding changes will also be made here.
Add primary key
Alter table table name Add constraint primarykey primary key (primary key field name)
The first primarykey is the same as the above. It is the name of the Primary Key Integrity Constraint. The following primary key (primary key field) is of course the primary key constraint phrase. In addition to the primary key, it can also be the foreign key or check phrase.
For details, refer to the usage of constraint. It is used to add integrity constraints and specify the name of the constraints (so that you can delete the constraints later ). Constrain can also be used in the create statement to set constraints such as primary key, foreign key, and check when creating a table.