갸 꿀~~~
이관 정합성 확인 쿼리
select table_schema
,concat(if(group_concat(SIZE separator '')!='',group_concat(SIZE separator ''),'0'),'(MB)') as "SIZE(MB)"
,if(group_concat(TAB separator '')!='',group_concat(TAB separator ''),'0') as "TABLE"
,if(group_concat(idx separator '')!='',group_concat(idx separator ''),'0') as "INDEX"
,if(group_concat(vie separator '')!='',group_concat(vie separator ''),'0') as "VIEW"
,if(group_concat(PRO separator '')!='',group_concat(PRO separator ''),'0') as "PROCEDURE"
,if(group_concat(FUNC separator '')!='',group_concat(FUNC separator ''),'0') as "FUNCTION"
,if(group_concat(TRI separator '')!='',group_concat(TRI separator ''),'0') as "TRIGGER"
,if(group_concat(EVN separator '')!='',group_concat(EVN separator ''),'0') as "EVENT"
from
(
select
table_schema,
if(object_type='SIZE',cnt,'') as "SIZE",
if(object_type='TABLE',cnt,'') as "TAB",
if(object_type='INDEX',cnt,'') as "idx",
if(object_type='VIEW',cnt,'') as "vie",
if(object_type='PROCEDURE',cnt,'') as "PRO",
if(object_type='FUNCTION',cnt,'') as "FUNC",
if(object_type='Trigger',cnt,'') as "TRI",
if(object_type='Event',cnt,'') as "EVN"
from (
SELECT 'SIZE' AS 'OBJECT_TYPE',TABLE_SCHEMA,round(sum(data_length+index_length)/1024/1024,0) as cnt from information_schema.tables where table_schema not in ('mysql','performance_schema','information_schema','sys') group by table_schema
union
select 'TABLE' as 'Object_type',table_schema,count(*) as cnt from information_schema.tables where table_schema not in ('mysql','performance_schema','information_schema','sys') group by table_schema
union
select 'INDEX' as 'Object_type' ,database_name,count(*) as cnt from
mysql.innodb_index_stats where database_name not in ('mysql','performance_schema','information_schema','sys') group by database_name
union
select 'VIEW' as 'Object_type',table_schema,count(*) as cnt
from information_schema.views where table_schema not in ('mysql','performance_schema','information_schema','sys') group by table_schema
union
select ROUTINE_TYPE as 'Object_type',routine_schema,count(ROUTINE_NAME) as cnt FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_schema not in ('mysql','performance_schema','information_schema','sys') and
ROUTINE_TYPE in ("PROCEDURE","FUNCTION") group by ROUTINE_TYPE,routine_schema
union
select 'Trigger' as 'Object_type',TRIGGER_SCHEMA,count(*) as cnt from INFORMATION_SCHEMA.TRIGGERS where trigger_schema not in ('mysql','performance_schema','information_schema','sys') group by trigger_schema
union
select 'Event' as 'Object_type', event_schema,count(*) as cnt from INFORMATION_SCHEMA.events where event_schema not in ('mysql','performance_schema','information_schema','sys') group by event_schema)a ) B group by table_schema order by table_schema;