How can I find which column is the primary key of a table by using a query?
The following query gives the list of all the primary keys in the given database.
SELECT DISTINCT TABLE_NAME ,column_name FROM INFORMATION_SCHEMA.key_column_usage WHERE TABLE_SCHEMA IN ('*your_db_name*');