建议使用postgres工具来发现架构和数据之间的差异 [英] suggest a postgres tool to find the difference between the schema and the data
问题描述
亲爱的所有人,
谁能建议我Linux的postgres工具,该工具用于查找两个给定数据库之间的
差异
Dear all ,
Can any one suggest me the postgres tool for linux which is used to find the
difference between the 2 given database
我尝试了apgdiff 2.3,但它在模式方面提供了区别,而不是数据
,但是我需要两者!
预先感谢!
I tried with the apgdiff 2.3 but it gives the difference in terms of schema not the data
but I need both !
Thanks in advance !
推荐答案
比较数据并不容易,尤其是在数据库很大的情况下。我创建了Python程序,该程序可以将PostgreSQL数据模式转储到可以通过第三方差异程序轻松比较的文件: http://code.activestate.com/recipes/576557-dump-postgresql-db-schema-to-text/?in=user-186902
Comparing data is not easy especially if your database is huge. I created Python program that can dump PostgreSQL data schema to file that can be easily compared via 3rd party diff programm: http://code.activestate.com/recipes/576557-dump-postgresql-db-schema-to-text/?in=user-186902
我认为可以通过将所有表数据转储到单独的CSV文件中来扩展该程序,类似于PostgreSQL COPY
命令。请记住在 SELECT ...
查询中添加相同的 ORDER BY
。我创建了一个从文件中读取 SELECT
语句并将结果保存在单独文件中的工具。这样,我可以管理要比较的表和字段(并非所有字段都可以在 ORDER BY
中使用,并且并非所有字段对我来说都很重要)。可以使用转储模式实用程序轻松创建这种配置。
I think that this program can be extended by dumping all tables data into separate CSV files, similar to those used by PostgreSQL COPY
command. Remember to add the same ORDER BY
in SELECT ...
queries. I have created tool that reads SELECT
statements from file and saves results in separate files. This way I can manage which tables and fields I want to compare (not all fields can be used in ORDER BY
, and not all are important for me). Such configuration can be easily created using "dump schema" utility.
这篇关于建议使用postgres工具来发现架构和数据之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!