PG 数据库结构比对工具 apgdiff
简介
https://github.com/fordfrog/apgdiff
Another PostgreSQL Diff Tool is free PostgreSQL diff tool that is useful for comparison/diffing of database schemas. You can find more information at its website at http://www.apgdiff.com/.
apgdiff工具,可用于数据库的比较/差异化 模式。该工具比较两个数据库转储文件并创建输出 使用可用于将旧数据库架构更新为的DDL语句 新建一个或查看两个数据库到底有什么不同。
更多内容请参考:http://www.apgdiff.com/
安装使用
apgdiff是一个Java程序,所以,需要先安装Java。
1 2 | wget https://codeload.github.com/fordfrog/apgdiff/tar.gz/refs/tags/release_2.7.0 -O apgdiff_2.7.0.tar.gz tar -zxvf apgdiff_2.7.0.tar.gz |
命令:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | [pg13@lhrpgall soft]$ java -jar /soft/apgdiff-release_2.7.0/releases/apgdiff-2.7.0.jar -h ERROR: Unknown option: -h Usage: apgdiff [options] <old_dump> <new_dump> Options: --version: displays apgdiff version --add-defaults: adds DEFAULT ... in case new column has NOT NULL constraint but no default value (the default value is dropped later). --add-transaction: adds START TRANSACTION and COMMIT TRANSACTION to generated diff file. --ignore-function-whitespace: ignores multiple spaces and new lines when comparing content of functions - WARNING: this may cause functions to appear to be same in cases they are not, so use this feature only if you know what you are doing. --ignore-start-with: ignores START WITH modifications on SEQUENCEs (default: do not ignore these changes). --ignore-schema-creation: Removes the need of CREATE SCHEMA command on the input schemas --in-charset-name <charset>: charset that should be used for reading input files (standard charset name supported by Java; the default is UTF-8). --out-charset-name <charset>: charset that should be used for writing output (standard charset name supported by Java, default is UTF-8) --output-ignored-statements: outputs information about DDL statements that apgdiff ignores at this moment (it will not output any SELECT, INSERT, UPDATE and/or DELETE statements). --ignore-slony-triggers: when parsing SQL statements, ignores Slony triggers named _slony_logtrigger and _slony_denyaccess. --list-charsets lists all supported charsets |
示例
1 2 3 4 | pg_dump -h 172.72.6.30 -U postgres -p 5432 -d lhrdb -f pg30.dump pg_dump -h 172.72.6.31 -U postgres -p 5432 -d lhrdb -f pg31.dump java -jar /soft/apgdiff-release_2.7.0/releases/apgdiff-2.7.0.jar --ignore-start-with pg30.dump pg31.dump > diff.sql |