SchemaSpy is a neat tool to produce visual diagrams for most relational databases.
Here's how to use it to generate schema relationship diagrams for PostgreSQL databases:
-
Download the jar file from here (the current version is v6.1.0)
-
Get the PostgreSQL JDBC driver (unless your installed version of java is really old, use the latest JDBC4 jar file)
-
Run the command against an existing database. For most databases, the schema (-s option) we are interested in is the public one:
java -jar schemaspy-6.1.0.jar -t pgsql \
-s public -db [db name] -u [db user] -p [password] \
-host localhost -o /tmp \
-dp /path/to/JDBC/driver/postgresql-42.2.12.jar
The above example sends all the output to the /tmp folder, but that can be changed as desired.
SchemaSpy produces several different diagrams, but the main summary diagram is in:
/tmp/diagrams/summary/relationships.real.large.png.
Hi i am not able to do the same i am getting error as
C:\Users\administrator\Downloads>java -jar postgresql-42.2.1.jre7.jar -t pgsql -s public -db cx_assesshub_v1.0 -u postgres -p assesshub -host localhost -o /tmp-dp C:\Users\administrator.m2\repository\postgresql\postgresql\9.2-1002.jdbc4\postgresql-9.2-1002.jdbc4.jar
PostgreSQL JDBC Driver 42.2.1.jre7Found in: jar:file:/C:/Users/administrator/Downloads/postgresql-42.2.1.jre7.jar!/org/postgresql/Driver.classThe PgJDBC driver is not an executable Java program.You must install it according to the JDBC driver installation instructions for your application / container / appserver, then use it by specifying a JDBC URL of the form jdbc:postgresql://or using an application specific method.See the PgJDBC documentation: http://jdbc.postgresql.org/documentation/head/index.htmlThis command has had no effect.