sql语句:因为MySQL 没有full outer join,所以用left join union all right join来实现
select a.table_schema,
a.table_name,
a.column_name,
b.table_schema,
b.table_name,
b.column_name
from information_schema.columns a
left join information_schema.columns b on a.table_name = b.table_name and a.column_name =
b.column_name andb.table_schema = 'DBNAMe1'
where a.table_schema = 'DBNAME2' and
(b.table_name is null or
b.column_name is null)
union all
select a.table_schema,
a.table_name,
a.column_name,
b.table_schema,
b.table_name,
b.column_name
from information_schema.columns a
left join information_schema.columns b on a.table_name = b.table_name and a.column_name =
b.column_name andb.table_schema = 'DBNAME2'
where a.table_schema = 'DBNAME1' and
(b.table_name is null or
b.column_name is NULL)
先把每个库的表结构导出到文件,然后比较这两个文件。mysqldump --skip-comments --skip-extended-insert -u root -p database1>file1.sql
mysqldump --skip-comments --skip-extended-insert -u root -p database2>file2.sql
diff file1.sql file2.sql
其实还有一些比较工具,推荐一个
mysql-comparison-tools
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)