select distinct TABLE_SCHEMA ,
TABLE_NAME ,
CONSTRAINT_NAME , COLUMN_NAME from information_schema.key_column_usage m where exists (
select 1 from (select
TABLE_SCHEMA , CONSTRAINT_NAME
from
(
select
distinct TABLE_SCHEMA ,
TABLE_NAME ,
CONSTRAINT_NAME
from
information_schema.key_column_usage t
where
t.CONSTRAINT_SCHEMA in ('jats001' , 'impuser' , 'frisk') and t.CONSTRAINT_NAME not in('PRIMARY')) t group by TABLE_SCHEMA , CONSTRAINT_NAME having count(*) > 1 ) rp where m.TABLE_SCHEMA = rp.TABLE_SCHEMA and m.CONSTRAINT_NAME = rp.CONSTRAINT_NAME
)
select distinct INDEX_SCHEMA ,
TABLE_NAME ,
INDEX_NAME, COLUMN_NAME from
information_schema.statistics m
where exists (select 1 from (
select
INDEX_SCHEMA ,
INDEX_NAME
from
(
select
distinct INDEX_SCHEMA ,
TABLE_NAME ,
INDEX_NAME
from
information_schema.statistics t
where
t.TABLE_SCHEMA in ('jats001' , 'impuser' , 'frisk') and t.INDEX_NAME not in ('PRIMARY')) t
group by
INDEX_SCHEMA ,
INDEX_NAME
having
count(*) > 1) rp where m.INDEX_SCHEMA = rp.INDEX_SCHEMA and m.INDEX_NAME = rp.INDEX_NAME)
MySQL查询名称重复的约束与索引
最新推荐文章于 2024-11-14 15:58:00 发布