Mysql table list out all primary key tables

Mysql table list out all primary key tables

Solution:
SELECT k.COLUMN_NAME,k.TABLE_NAME
FROM information_schema.table_constraints t
LEFT JOIN information_schema.key_column_usage k
USING(constraint_name,table_schema,table_name)
WHERE t.constraint_type='PRIMARY KEY'
    AND t.table_schema=DATABASE();

Post a Comment

0 Comments