select constraint_name
from information_schema.table_constraints
where table_name = 'mytable'
and table_schema = 'myschema'
and constraint_name = 'PRIMARY';
SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_schema = schema()
AND column_key = 'PRI'
AND table_name = 'my_table_name'
AND column_name = 'column_name';
2条答案
按热度按时间bis0qfac1#
我想你需要下面的陈述
https://www.db-fiddle.com/f/jbdzxwpwkyichsbl1ib2rj/2
或以下https://www.db-fiddle.com/f/jbdzxwpwkyichsbl1ib2rj/3
zazmityj2#