Multiple Primary Keys

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm studying a sample database and discovered some tables that have 2 two
Primary keys in the same table. I have not been able to recreate the table
with the multiple primary keys. My questions in why having more than one PK
in the same table? How can I insert second PK in a table. Thanks and
regards.
 
Sokan33 said:
I'm studying a sample database and discovered some tables that have 2
two Primary keys in the same table. I have not been able to recreate
the table with the multiple primary keys. My questions in why having
more than one PK in the same table? How can I insert second PK in a
table. Thanks and regards.

You are not seeing multiple Primary Keys. You are seeing ONE Primary Key
that happens to consist of two or more fields. A PK is like an index in
that it can consist of up to 10 fields.

To create a multi-field PK select a field in design view and then while
holding the control key select additional ones. When all of the desired
fields are highlighted at once press the "Key" button in the toolbar.
 
By definition, a table cannot have more than 1 primary key. Perhaps what you
are seeing is a compound primary key - a SINGLE primary key made up of
multiple fields in the table. When viewing the index pane, if the index name
column is blank next to non-blank field name, then that field is part of a
compound index.
 
Back
Top