mysql 查询指定数据库,指定表的主键名 SELECT k.column_name, k.table_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 k.table_name = '表名' AND t.table_schema = '数据库名';