Include and Exclude Stuff from the Output
Create diff-able Output
Integrations
How to Use SchemaCrawler in Projects
Advanced SchemaCrawler Usage
Re-run SchemaCrawler with
-loglevel=ALL
on the command-line.
| [top] |
Change the configuration for the SchemaCrawler the table or column
include and exclude patterns in the
schemacrawler.config.properties
file. The include or exclude specification is a
Java regular expression
. The include pattern is evaluated first, and the exclusions are
made from the included tables or columns
list.
Also see the filtering and grep command-line options.
| [top] |
Change the configuration for the SchemaCrawler table types to
schemacrawler.table_types=TABLE
in the
schemacrawler.config.properties
file.
The option in the configuration can be overridden by the -table_types command-line option. Further, see the details on the command-line options.
| [top] |
Change the configuration for the SchemaCrawler stored procedures to
schemacrawler.show_stored_procedures=false
in the
schemacrawler.config.properties
file.
The option in the configuration can be overridden by the -show_stored_procedures command-line option. Further, see the details on the command-line options.
| [top] |
Change the configuration for the SchemaCrawler "sort
alphabetically" properties in the
schemacrawler.config.properties
file. Also see the
sorting command-line options.
| [top] |
Change the configuration for the SchemaCrawler
schemacrawler.format.show_standard_column_type_names=true
in the
schemacrawler.config.properties
file. This setting will show standard data types across different
database systems. On the other hand, if you
want to see the real database specific data types, change the setting
to a value of true.
| [top] |
When columns are added into a table, they can change the column
ordinal number. This can mess up the diffs.
Change the configuration for the SchemaCrawler
schemacrawler.format.show_ordinal_numbers=false
in the
schemacrawler.config.properties
file. You can combine this setting with the setting to sort columns
alphabetically to produce diff friendly
output.
| [top] |
If primary key, foreign key and index names are not explicitly
provided while creating a schema, most database
system assign default names. These names can show up as spurious diffs in
SchemaCrawler output. Change the
configuration for the following properties in your
schemacrawler.config.properties
file.
schemacrawler.format.hide_primarykey_names=false schemacrawler.format.hide_foreignkey_names=false schemacrawler.format.hide_index_names=false schemacrawler.format.hide_constraint_names=false
| [top] |
When SchemaCrawler is used with J2SE 6 and above, it has built-in
support to be used with JavaScript scripts.
Write your JavaScript file, assuming that a "database" variable
containing the database schema will be available.
A "connection" variable will also be available, and you will be able
to execute SQL against your database.
Run
schemacrawler.tools.integration.scripting.Main
, with the correct options. See the example in the
examples\javascript
directory for more details.
| [top] |
SchemaCrawler integrates with
Apache Velocity
to allow for templated ouput. Put Velocity on your classpath, and
create your template, and run
schemacrawler.tools.integration.velocity.Main
, with the correct options. See the Velocity example in the
_distrib\velocity
directory for more details.
| [top] |
SchemaCrawler integrates with
Graphviz
to produce graph images. Install Graphviz, and run
schemacrawler.tools.integration.graph.Main
, with the correct options, for example,
-outputformat png -outputfile=graph.png
. See the diagram example in the
_distrib\diagram
directory for more details.
An example of a SchemaCrawler database diagram:
| [top] |
Read Java API Makes Database Metadata as Easily Accessible as POJOs for an introduction to the SchemaCrawler API. (This article may refer to an older release of the SchemaCrawler API, but the concepts are the same.) You can also browse the javadocs .
See the example in the
_distrib\examples\api
directory.
Or, if you are impatient, try code similar to the following:
final SchemaCrawlerOptions options = new SchemaCrawlerOptions();
// Set what details are required in the schema - this affects the
// time taken to crawl the schema
options.setSchemaInfoLevel(SchemaInfoLevel.standard());
final Database database = SchemaCrawlerUtility.getDatabase(connection, options);
for (final Catalog catalog: database.getCatalogs())
{
for (final Schema schema: catalog.getSchemas())
{
System.out.println(schema);
for (final Table table: schema.getTables())
{
System.out.print("o--> " + table);
for (final Column column: table.getColumns())
{
System.out.println(" o--> " + column);
}
}
}
}
| [top] |
SchemaCrawler comes with a full-featured ant task.
See the example in the
_distrib\examples\ant-task
directory.
In addition to the ant task parameters mentioned in the example, you may find the following parameters useful.
| [top] |
SchemaCrawler comes with a Maven reports plug-in. You can generate a SchemaCrawler report along with other reports for your Maven generated site.
See the example in the
_distrib\examples\maven
directory.
Install the SchemaCrawler Maven plug-in by running the following
command, and following the instructions that
are printed out.
java -cp schemacrawler-7.4.jar schemacrawler.tools.integration.maven.Main
Next, add a section to your Maven 2.0 project's pom.xml file, similar to that below, changing what needs to be changed:
<reporting>
<plugins>
<plugin>
<groupId>schemacrawler</groupId>
<artifactId>schemacrawler-maven-plugin</artifactId>
<version>7.4</version>
<configuration>
<schemacrawler.config>schemacrawler.config.properties</schemacrawler.config>
<schemacrawler.datasource>hsqldb</schemacrawler.datasource>
<schemacrawler.command>verbose_schema</schemacrawler.command>
<schemacrawler.outputformat>html</schemacrawler.outputformat>
<schemacrawler.jdbc.driver.classpath>hsqldb.jar</schemacrawler.jdbc.driver.classpath>
</configuration>
</plugin>
</plugins>
</reporting>
Run
mvn site
. See the output produced in the
target/site
directory of your project.
| [top] |
See the documentation in INFORMATION_SCHEMA Views .
| [top] |
See the documentation in INFORMATION_SCHEMA Views .
| [top] |
Tables are sorted in alphabetical order by default. If you turn
alphabetical sorting off, the tables
will be displayed in "create" order - that is, tables with no
foreign-key dependencies will be displayed first. The "drop" order is
the reverse of the "create" order. Use the following command-line
arguments to obtain tables in "create" order:
-command=brief_schema -sorttables=false -show_stored_procedures=false
| [top] |