Created
June 21, 2011 04:33
-
-
Save jachin/1037246 to your computer and use it in GitHub Desktop.
Select the primary key for a table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT k.column_name | |
FROM information_schema.table_constraints t | |
JOIN information_schema.key_column_usage k | |
USING(constraint_name,table_schema,table_name) | |
WHERE t.constraint_type='PRIMARY KEY' | |
AND t.table_schema='db' | |
AND t.table_name='tbl'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://lists.mysql.com/mysql/204944