Create stylish ER diagrams on Mac (Oracle)

What is "Schema Spy"?

Java-made ER diagram generation tool. By using JDBC driver, you can generate ER diagram from various DBs such as Oracle, SQL Server, MySQL and PostgreSQL. In addition to the ER diagram, the definitions of tables and constraints are also plotted as a set.

The overall stylish design allows you to grin after it is generated.

environment

setup

Download Schema Spy

Download from the following URL. https://github.com/schemaspy/schemaspy#schemaspy-v600-rc2

The current version of 5.0.0 is not stylish, so download SchemaSpy v6.0.0 RC2.

Java 8 installation

Java is required for Schema Spy to work, so install it. If you have already installed it, skip it.

Click [Mac OS X] from the following URL to download the installer. https://java.com/en/download/manual.jsp

Run the .dmg file to install.

Install Graphviz

"Graphviz" is a tool that converts a text file written in the dot language format into a graph and outputs it as an image. Schema Spy uses it for ER diagram output.

For Mac, install from Homebrew.

$ brew install graphviz --with-librsvg --with-pango

If only brew install graphviz is used, the" -Tcmapx' failed with return code 139 "error will occur and the ER diagram will not be generated. https://github.com/schemaspy/schemaspy/issues/33

JDBC driver download

"JDBC driver" is middleware for operating DB from Java application. "JDBC" is an abbreviation for "Java Database Connectivity".

Each vendor has a different driver and is usually distributed by each vendor. Oracle also distributes it on the official website, and downloads the JDBC driver according to the version. http://www.oracle.com/technetwork/jp/database/features/jdbc/index-099275-ja.html

In my case, the JDBC driver was included in the environment where Oracle was installed, so I used that.

Table definition / ER diagram generation

At this point, you're ready to go. Execute the following command to generate the table definition and ER diagram. Depending on the number of tables and columns, it can take tens of seconds to minutes to generate.

# java -jar {schemaspy.jar path} -t {DB type} -dp {JDBC driver path} -db {DB name} -host {hostname} -port {port number} [-s {Schema name}] -u {username} [-p {password}] -o {Output destination path} -gv {GraphViz folder path} -cat %
$ java -jar schemaspy-6.0.0-rc2.jar -t orathin -dp ./drivers/ojdbc14.jar -db testdb -host 192.168.10.1 -port 1521 -s TESTSCHEMA -u testuser -p testpass -o ./output -gv /usr/local/Cellar/graphviz/2.40.1 -cat %

Specify "orathin" as the DB type. The default port number for Oracle is "1521".

For Oracle, omitting the schema name resulted in an error. Please note that the schema name is case sensitive.

If you do not add -cat%, an "ERROR --Catalog name can't be null" error will occur and you will not be able to generate it. https://github.com/schemaspy/schemaspy/issues/160

Table definition / ER diagram reference

Table definitions etc. are output in HTML format. You can refer to it by simply opening "index.html" directly under the output destination path with a web browser.

Reference link

Recommended Posts

Create stylish ER diagrams on Mac (Oracle)
Create a Java development environment using jenv on Mac
Install gradle on mac
Install Java on Mac
Install openjdk11 on mac
Install OpenJDK 8 on mac