此查询完成了比较mysql上的2个表结构的工作:
select column_name ,max(case when table_name = 'table_1' then 'Yes' end) as in_table_1 ,max(case when table_name = 'table_2' then 'Yes' end) as in_table_2 from information_schema.columns where table_name in('table_1', 'table_2') and table_schema = 'your_database' group by column_name order by column_name;
但是它会将列名转换为小型大写字母,有人知道如何调整它来比较具有混合小型和大型上限的列吗?