How to make composite primary key on phpmyadmin

MysqlPhpmyadminComposite Key

Mysql Problem Overview


How to make a composite primary key on phpmyadmin. such that student id is combination of year and roll number. sid = 112132 , 11 of year 2011 and 2132 is roll number?? anybody help..

Mysql Solutions


Solution 1 - Mysql

If the table is already created:

  1. From the "Structure" pane, check the boxes to the left of all field names you want included in the primary key. (For example, in an order items table, you might check "order ID" and "line item number".)
  2. Then click "Primary" in the "With selected:" list of operations just below the field names.

enter image description here

You can now also define the keys while creating the table as mentioned in @amila's answer

Solution 2 - Mysql

Make the index of the required attributes to primary at the time of creating the table.The foloowing figure explains it in Phpmy admin.enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser3427877View Question on Stackoverflow
Solution 1 - MysqlJunaidView Answer on Stackoverflow
Solution 2 - MysqlAmila WeerasingheView Answer on Stackoverflow