Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make composite primary key on phpmyadmin

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..

like image 891
user3427877 Avatar asked Mar 17 '14 07:03

user3427877


People also ask

How do I add a composite primary key in phpMyAdmin?

Go to table structure tab and select all columns which you wish to set as combination of primary keys and from horizontal options at bottom (just above the border), click to Primary which will set them as composite primary key.

How do you make a composite primary key?

A Composite Primary Key is created by combining two or more columns in a table that can be used to uniquely identify each row in the table when the columns are combined, but it does not guarantee uniqueness when taken individually, or it can also be understood as a primary key created by combining two or more ...

How do I set primary key in phpMyAdmin?

Adding a Primary Key to a New Table In phpMyAdmin. When creating a new table in phpMyAdmin, select PRIMARY from the Index dropdown on the column that will be the primary key. Check the box in the A_I column if this will be an auto incrementing key.


1 Answers

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

like image 181
Junaid Avatar answered Sep 17 '22 15:09

Junaid