Get Primary key Column Name

Public

Get raw version
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='YourDatabase'
  7. AND t.TABLE_NAME='YourTable';