208

Are there any free tools to generate table diagrams with PostgreSQL?

4
  • 8
    Since this question got closed, I asked on the software recommendation SE: Generate database table diagrams from a PostgreSQL database Commented Jul 9, 2016 at 21:46
  • 1
    Would be better and helpful to add a suggestion on what appropriate site under Stack Exchange communities to ask. Commented Jun 7, 2021 at 18:47
  • In one word, dbeaver. Works out of the box. Also, you can refer to wiki.postgresql.org/wiki/Design_Tools Commented Apr 20, 2022 at 12:58
  • One great solution would be using intellij idea / datagrip's: Right-click on the database's table name > Diagram > Show Visualization -> Some icon in the top for Export Diagram > Open in Web Editor > (Choose whichever you like more) Commented Oct 27, 2022 at 23:42

7 Answers 7

221

I love schemaspy for schema visualisations. Look at the sample output they provide, and drool. Note the tabs!

You'll need to download the JDBC driver here, then your command should look something like:

java -jar schemaspy-6.0.0-rc2.jar -t pgsql -db database_name -host myhost -u username -p password -o ./schemaspy -dp postgresql-9.3-1100.jdbc3.jar -s public -noads

Sometimes using options -port will not working if your database has diferrent port, so you have to add manual port after host parameter, for example:

java -jar schemaspy-6.0.0-rc2.jar -t pgsql -db database_name -host myhost:myport -u username -p password -o ./schemaspy -dp postgresql-9.3-1100.jdbc3.jar -s public -noads

You'll need to install graphviz as well if you want graphics (apt-get install graphviz for debian based distros).

Sign up to request clarification or add additional context in comments.

14 Comments

Actually it's graphviz :)
Schemaspy did this trick on first try. Layout of generate graph was great (even on our complex table set). When 100 tables reference the same table there will be overlapping lines; however the overall layout compensates for this and is perfectly legible/traceable.
for graphviz just append the -gv /path_to/graphviz to the command
On mac I had to add: -renderer :quartz to avoid this error: -Tcmapx' failed with return code 139
To run this using Docker on the mac: docker run -v `pwd`/diagram:/output schemaspy/schemaspy:snapshot -t pgsql --port 5432 -u postgres -db <dbname> -host docker.for.mac.localhost -p <password>
|
33

SchemaCrawler for PostgreSQL can generate database diagrams from the command line, with the help of GraphViz. You can use regular expressions to include and exclude tables and columns. It can also infer relationships between tables using common naming conventions, if not foreign keys are defined.

Comments

20

Quick solution I found was inside the pgAdmin program for windows. Under Tools menu there is a "Query Tool". Inside the Query Tool there is a Graphical Query Builder that can quickly show the database tables details. Good for a basic view

4 Comments

I can't see how to automatically draw relationships using foreign keys in pgAdmin 1.20.0. Is it supported?
Nice tip, although it seems you have to draw all the FKs yourself using query joins.
This feature was removed in PgAdmin 4 in 2016. It might be reimplemented but has not been as of 2019.
See this answer for how to generate an ERD in pgAdmin 4 version 30 or higher.
14

Check the wiki: http://wiki.postgresql.org/wiki/Community_Guide_to_PostgreSQL_GUI_Tools

Comments

9

Just found http://www.sqlpower.ca/page/architect through the Postgres Community Guide mentioned by Frank Heikens. It can easily generate a diagram, and then lets you adjust the connectors!

1 Comment

I couldn't get this to work; kept getting ArrayIndexOutOfBoundException
7

PostgreSQL Autodoc has worked well for me. It is a simple command line tool. From the web page:

This is a utility which will run through PostgreSQL system tables and returns HTML, Dot, Dia and DocBook XML which describes the database.

5 Comments

Link in answer is broken. Googled and found: github.com/cbbrowne/autodoc but seems to be unmaintained.
@nelsonic Indeed. Should I swap the links, or not? It doesn't seem to be by the same person who was maintaining it. Some kind of fork, it looks like.
I've asked the author on GitHub if the project is being maintained: github.com/cbbrowne/autodoc/issues/2
@nelsonic Yes, I saw the reply. I also posted bugs.debian.org/820208
You can create a png from the dot file as such: dot -Tpng my_database.dot -o my_database.png.
2

Inside Eclipse I've used the Clay plugin (ex Clay-Azurri). The free version allows to introspect ("reverse engineer") an existing DB schema (via JDBC) and make a diagram of some selected tables.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.