"mysql: determine table's primary key dynamically" Answer’s

SHOW INDEX FROM <tablename>

You want the row where Key_name = PRIMARY


You'll probably want to cache the results -- it takes a while to run SHOW statements on all the tables you might need to work with.

Wednesday, March 31, 2021
answered 11 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :