如何比较mysql数据库的表结构和表内容的差异

如何比较mysql数据库的表结构和表内容的差异,第1张

先把每个库的表结构导出到文件,然后比较这两个文件。

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

select t1.*, t2.*

from 真实表 t1 full join 临时表 using (id) //using也可写成on t1.id=t2.id

where t1.f!=t2.f or (t1.f is null and t2.f is not null) or (t1.f is not null and t2.f is null)


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6110963.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-15
下一篇 2023-03-15

发表评论

登录后才能评论

评论列表(0条)

保存