Posted By

jachin on 12/17/08


mysql PrimaryKey InformationSchema

Versions (?)

Select the primary key for a table

 / Published in: SQL


  1. SELECT k.column_name
  2. FROM information_schema.table_constraints t
  3. JOIN information_schema.key_column_usage k
  4. USING(constraint_name,table_schema,table_name)
  5. WHERE t.constraint_type='PRIMARY KEY'
  6. AND t.table_schema='db'
  7. AND t.table_name='tbl';

Report this snippet  

You need to login to post a comment.