Database administration for fun and profit

HTML documentation for a database schema

table Some time ago I was looking for a “quick and dirty” way of generating HTML documentation of one of my clients’ database schema. I didn’t need an ER diagram – just a list of tables to insert into a word document. At that time TOAD for DB2 did not exist, so I could not use it for my purpose.

Eventually, I ended up creating a simple solution for that simple problem, using a SQL script fetching information from the database catalog and an XSL template to transform its output into HTML, similar to this.

tbldoc is just a bunch of SQL scripts, XSD and XSL files, and a sample CSS style sheet that all serve a single purpose: to create simple documents describing tables and views in a database.

The information that is extracted from a database system catalog contains description of each column of each (specified) table and view. That information is saved as an XML document that conforms to the provided schema. An XSL transformation can then be applied to that XML in order to produce an HTML representation of the catalog data.

Internet Explorer and Firefox can perform transformation of XML documents “on the fly”, so opening XML file in one of those browsers presents a nicely formatted database catalog. Here is a sample.

The HTML file can be viewed online, copied and pasted into a word processing program, or opened directly by such program (e.g. Microsoft Word).

Database system catalog contents differ from vendor to vendor and from
version to version. For this reason the SQL query used to extract catalog
information would be different in each case. For now I only have a script for DB2 UDB v8.

If you think it can be useful for you please download the archive and freely use the tool.

6 Responses to HTML documentation for a database schema

  1. Ramesh says:


    Thanks for sharing this tool.
    The archive that you provided here is corrupted, I couldn’t be able to extract the files.


  2. nick says:

    The archive seems to be ok, actually. WinZip handles it without problems. Also please try “gzip -d -c | tar xvf -“.

  3. Pingback: Pythian Group Blog » Log Buffer #28: a Carnival of the Vanities for DBAs

  4. Pingback: Neat example of XML and XSL with a DB2 twist ~ Daily Life Health Beauty About The All New Tips

  5. Pingback: Log Buffer #28: A Carnival of the Vanities for DBAs

  6. bo,liu says:

    very good idea, thank you very much for share

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.