When you create a Microsoft Access table, Access will automatically create a primary key to your database table, but you can also specify the field you want as the primary key for your database table.
The Primary key in Microsoft Access is a field or set of fields with unique values throughout the table. The primary key offers several characteristics, such as it uniquely identifies each row in the database, It always contains a value, it is never empty, and the value contains never change.
How to add or remove Primary Key in Table in Access
To add and remove a Primary Key from an Access database table, follow the methods below.
1] How to remove the default Primary key from Access Table
Open the database that you want to alter.
On the navigation pane on the left, click the table that contains the field size you want to change.
Then click the Design view.
By default, Access will add a Primary key to your table, but in some cases, you would want a different field as the primary key.
Change the field’s data type with the default primary key, from Auto-Number to Number, by clicking the drop-down arrow of the Data Type and choosing the Number Data Type.
Then right-click the Primary Key icon and select Primary Key.
The other method to remove the Primary key is to click the Primary Key button on the menu bar, and the primary key is removed from the field.
Then click Save on the Quick Access toolbar.
2] How to add a new Primary Key to the Access table
We will add the new primary key to the field that we want to become the primary key.
Delete the field you want to become the primary key because once you enter data in a table, you cannot change the data type of any field to AutoNumber even if you have not added any data type to the field.
The AutoNumber field makes an excellent primary key, and Access does not allow two AutoNumber data types in an Access table, only one.
Add a new row to the table and name the field the name of the field you deleted.
Make the field an AutoNumber data type.
Then right-click the field and select Primary Key from the context menu.
The other method to add the Primary key is to click the Primary Key button on the menu bar.
Then click Save after the primary key is added to the field.
Can we have two Primary keys in Access table?
No, you cannot have two primary keys in a table. Each table in Microsoft Access can only be able to have one primary key.
What is the purpose of the Primary key in Access?
The primary key’s purpose is to promptly associate data from multiple tables and combine that data in a meaningful way.
We hope this tutorial helps you understand how to add and remove Primary Keys from an Access database table.