>How can I select primary key from a table?
To retrieve PKs for db.tbl in MySQL 5 ...
FROM information_schema.table_constraints t
JOIN information_schema.key_column_usage k
WHERE t.constraint_type='PRIMARY KEY'
Pre-5, parse the result of DESC tbl or SHOW KEYS FROM tbl.
> Hi folks. How can I select primary key from a table? I can't find
> any syntax out of show fields from tablename, and the 'key' field =
> "PRI". Just seems to be a bit much.
> Any takers?
> Rich in Toronto (cold)
> --MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> --No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.411 / Virus Database: 268.17.37/682 - Release Date:
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.411 / Virus Database: 268.17.37/682 - Release Date: 2/12/2007