Generally speaking, most tables we create in MySQL should have a primary key. A primary key is one or more columns that have been configured as the unique identifier for the table.
We usually create the primary key when creating the table, but we can also add a primary key to an existing table (assuming it doesn’t already have one).
Occasionally it might not be immediately apparent which column is the primary key for a given table. Or it might not be apparent whether or not the table has a composite primary key. Fortunately it’s easy enough to find out.
Below are five ways to get the primary key column/s from an existing table in MySQL.
Continue reading