Resolved: 2 columns as primary key
what if I want to make the primary key for 2 columns together
how can I name the primary key for the 2 named columns and how can we create a relation between them
like
(Primary key name for 2 columns)
I Purchase num column I Sales column I
I I I
I I I
I I I
Hi Peter!
Thanks for reaching out.
The syntax for defining a composite primary key is:
PRIMARY KEY(column_1, column_2)
.
In this case: PRIMARY KEY(Purchase_num_column, Sales_column)
. The names of the columns should not contain a space. Please, use an underscore for example.
Hope this helps.
Best,
Tsvetelin
Thank you
but the instructor said that you can have one and Only one primary Key, then how come that we can have 2 fields as a primiary keys, I'm lost