Home » mysql » Changing primary key of table

Changing primary key of table

We have a table basic profile with following table structure

we don’t want to use it as primary key so first we removed its auto increment the we will remove it from primary key
queries for these are

If you want to make primary key to some other column than we can use following query

above query will not make id1 as auto increment.
to make it a uto incremente we will execute following query insted of above

Now let us check the table description

We can also make composite primary key in existing table for that we use following query

This will make id1 and id2 primary key of table.

Please follow and like us:
error