我尝试了几个sql脚本,但是失败了。这是我最接近的一个:
SELECT *
FROM INFORMATION_SCHEMA.STATISTICS
WHERE table_schema = schema()
AND table_name = 'my_table_name'
AND index_name = 'column_name';
答案 0 :(得分:1)
我认为您需要以下声明
https://www.db-fiddle.com/f/jbdzXwpWkYichsBL1ib2Rj/2
VBA
或以下 https://www.db-fiddle.com/f/jbdzXwpWkYichsBL1ib2Rj/3
select constraint_name
from information_schema.table_constraints
where table_name = 'mytable'
and table_schema = 'myschema'
and constraint_name = 'PRIMARY'
and constraint_name = 'PRIMARY'
答案 1 :(得分:0)
SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_schema = schema()
AND column_key = 'PRI'
AND table_name = 'my_table_name'
AND column_name = 'column_name';