Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Check MySQL / MariaDB table for Primary Key

It is pretty straightforward to check a MySQL / MariaDB table for a Primary Key, connect to the db server, login or open up your favorite MySQL client.

Without selecting any table, issue the following command:

SHOW INDEXES FROM <TABLE> WHERE Key_name = 'PRIMARY'

Where <TABLE> is the name of the table you want to check.

The result returned should have a line show up with the Primary Key.

Note: If the result is empty, that means the table does not have a Primary Key.