SQLt/SQL::Translator/SQLFairy is a great tool to create ER diagrams from SQL:

SQL::Translator is a group of Perl modules that manipulate structured data definitions (mostly database schemas) in interesting ways, such as converting among different dialects of CREATE syntax (e.g., MySQL-to-Oracle), visualizations of schemas (pseudo-ER diagrams: GraphViz or GD), automatic code generation (using Class::DBI), converting non-RDBMS files to SQL schemas (xSV text files, Excel spreadsheets), serializing parsed schemas (via Storable, YAML and XML), creating documentation (HTML and POD), and more.

In Ubuntu Linux and Debian Linux, this can be obtained by installing SQLFairy:

apt-get install sqlfairy

This is quite useful if you follow a bottom-up approach: create the SQL first, and then create ER diagrams – although this might not be a common development method, it does have its uses, and some of us like it 🙂

So for instance, say you have a MySQL schema named sample.sql. To create a ER diagram with color, named sample_schema.png, run the following in the command line:

sqlt-diagram -d=MySQL -o=sample_schema.png sample.sql --color

where -d=MySQL specified the MySQL driver. Other available drivers can be obtained by:

sqlt -l

Additionally, sqlt can also be used to convert between various database schemas as well.