Access does not require a table to have a(n) primary key.

0
21
typewriter, mechanical, retro @ Pixabay

In this post, we will discuss the primary key. Primary keys are a necessity for tables that have data worth being tracked or modified. They also help with joining tables together in SQL queries and as columns in other tables.

In order to create a primary key, you need to insert a field into the table and give it an auto-incrementing number of ‘1’. This is all good and well if there is already something called ‘id’ on your table, but what if there isn’t? The answer is simple: just add one.

vintage, map, compass @ Pixabay

Not only do these two steps not require any code whatsoever, they don’t even require any additional fields on your table. We can also use the primary key as a column in another table, which is something some people don’t realise.

This will help with joining tables together if you need to go back and forth between them often but are unable to find any other field on one of the two that matches up with each other. All we have to do for this situation is add our new ID number from one table onto the end of an already existing identifier on the opposite side, separated by semi-colons (;). The format would look like so: customerID. In conclusion, I want you all to know that getting your own PK does not require creating a whole new table. You just need an ID called ‘id’ or adding it.

LEAVE A REPLY

Please enter your comment!
Please enter your name here