Mysql obtains the table metadata information primary key, primary key type, etc.:
we can directly obtain the relevant information we need according to the table name: for example, as follows
SELECT k.TABLE_NAME,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='crm' # 数据库名字
AND
t.table_name='t_customer' # 表名
The details can be changed according to the above requirements