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

0
SHOW INDEX FROM <tablename>

You want the row where Key_name = PRIMARY

http://dev.mysql.com/doc/refman/5.0/en/show-index.html

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
 
THEK
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 :