SchemaSpy

From PostgreSQL wiki

Jump to: navigation, search

About

SchemaSpyis a java tool that with the aid of Graphviz can generate a rough documentation for existing database as a collection of interlinked HTML pages.

Huge tables support

As of 2012-05-18, the latest jar file with SchemaSpy 5.0.0 incorrectly handles large number of rows, i.e. if it exceeds 2^31-1 . Therefore it is necessary to compile it from the source code. It is straightforward using Eclipse. Compiled version can be exported into a jar.

Default property file for PostgreSQL does not make use of efficient row estimation. Here is the snippet let's call it mypg.properties that can be used in place of default property file.

#
# see http://schemaspy.sourceforge.net/dbtypes.html
# for configuration / customization details
#
 
description=PostgreSQL
 
connectionSpec=jdbc:postgresql://<host>/<db>
host=some host
db=some db
 
driver=org.postgresql.Driver
 
# Sample path to the postgresql drivers.
# Use -dp to override.
driverPath=./postgresql-9.1-902.jdbc4.jar
 
selectRowCountSql=select reltuples as row_count from pg_class where relname=:table

Note that in spite of selectRowCountSql, last binary will fail in case of huge tables.

The tool can be called like

java -jar schemaSpy.jar -t ./mypg -db mydb -u myuser -host myhost -o output_folder -p mypass -schemas "public,something,else" -noviews

Shortcomings

Does not document table inheritance.

Personal tools