4 messages in com.mysql.lists.plusplusRe: primary key?
FromSent OnAttachments
Lisa N. Michaud18 Apr 2004 12:59 
Gregory Haley18 Apr 2004 14:17 
Lisa N. Michaud18 Apr 2004 14:20 
Paolo Brandoli19 Apr 2004 00:08 
Subject:Re: primary key?
From:Paolo Brandoli (pao@puntoexe.com)
Date:04/19/2004 12:08:13 AM
List:com.mysql.lists.plusplus

Execute the following query: show keys from YOUR_TABLE_NAME;

Then browse all the results and find the record where Key_name=PRIMARY. The field's name is stored in Column_name.

Have a nice day. Paolo

On Sunday, April 18, 2004, at 04:00 PM, Lisa N. Michaud wrote:

Is there a quick way to determine what field(s) is/are serving as the primary key for a given table?

I should have specified that I was looking for a way to figure it out through MySQL++ methods within a C++ program, not on the command line. Thanks for the responses so far, but that hasn't been what I am looking for.

I have figured out ONE way to do it - sending a "DESCRIBE table-name" query and parsing the results for "PRI" showing up in the 'KEY' field.

This is a kludge, so if anyone knows of a better way, do share.

--lisa