MySQL

How to Set Primary Key and Auto_increment in PHPMyAdmin

PhpMyAdmin is a tool that allows us to quickly view the state of our database and modify it, without having to write SQL queries. In this tutorial, we are going to see how to set the primary key and auto_increment in PHPMyAdmin.
 

How to Set Primary Key in PHPMyAdmin

1. First, select the database, in which you want to set the primary key.
 

 

 
2. In this tutorial, we are going to select the ‘gallery’ database, which contains the ‘gallery’ table. So click “Structure” from the menu at the top.
 

 
3. Now click on “Structure” from the “Action” column.
 

 
4. First check the box of the field you want to define as primary keys. Then click on the “Primary” button.
 

 
 
5. You should get a message like below:
 

 

How to Set Auto_increment in PHPMyAdmin

1. First, select the database, table and the column (e.g, id) in which you want to set the auto_increment value.
 

 
2. Next click on “Change” from the “Action” column.
 

 

 
3. Now check the box “A_I” which means “Auto_Increment”. Then click on the “Save” button.
 

 
4. You should get a message like below:
 

mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *