In MySQL, adding a composite primary key to an existing table is similar to adding a singular primary key. We define the primary key with the ALTER TABLE
statement.
However, when adding a composite primary key we need to use the ADD PRIMARY KEY
clause. We can’t define it at the column level. With singular primary keys on the other hand, we have the choice of using the ADD PRIMARY KEY
clause or applying it at the column level.