RDBMS-independent way to get table primary key?
For non-Drupal tables

I don't think there is a cross-db drupal way to do this currently.

It would have to be added to the database schema class for each database type.
For example, see the mysql database schema class and look at something like addIndex.

Something similar could be done for showIndex().
If it is added for all the different database handlers, it would then be able to be safely used.

Then a database API function would have to be added for easy calling.

For example you would need a db_show_index() function in database.inc like db_add_index().

For Drupal defined tables

You can use drupal_get_schema() and get the schema for a table; then, get what you need from that. It will return a schema as defined in hook_schema().

You might also be interested in some of the other schema API functions.

The schema will only be what was defined in hook_schema though. It won't pick up anything that has been added or changed outside of that.