SchemaCrawler Interactive Shell
SchemaCrawler Interactive Shell is an interactive shell environment that allows you to work with your database metadata.
The easiest way to learn how to use the SchemaCrawler Interactive Shell is by doing the online tutorial on Katacoda.
You can connect to a database, load the schema metadata catalog, and then execute commands against the metadata.
In order to use SchemaCrawler Interactive Shell, download the latest SchemaCrawler distribution. Unzip it, and follow instructions in the
shell example included with the distribution. You can start the SchemaCrawler Interactive Shell from the command-line with a
--shell argument. You can also download platform-specific SchemaCrawler installers to use the SchemaCrawler Interactive Shell.
Once the SchemaCrawler Interactive Shell starts up, you will get the
schemacrawler> command-prompt, and you can interact with SchemaCrawler using shell commands.
Example shell commands look like:
help connect --server <server> --host <host> --user <host> --password <password> --database <database> load --info-level maximum execute --command list
Results of command output can be redirected into a file. You can also generate schema diagrams. The schema metadata remains loaded as long as the shell is open, even if the database connection is closed.
SchemaCrawler Sequence of Operation
SchemaCrawler has a number of phases when executing a command. The phases run in this order, whether you are using the command-line or the SchemaCrawler interactive shell.
- connect: The first thing SchemaCrawler does is to connect to your database. There are two ways to connect - using a JDBC database connection URL, or, if a database plugin is available, using the server, host, port and database method. For more help, run
help connectin the SchemaCrawler interactive shell, or
-h connectfrom the command-line. To get a list of all available database plugins, run
help servers, or
-h serversfrom the command-line. To get specific help for a database plugin, run a command similar to
help server:mysql, or
-h server:mysql. And
-h drivers) to get a list of available JDBC drivers, so you can research on the internet about how to connect using a database connection URL.
- limit: Limit the tables and routines loaded into memory. This is an optional step, but is a good idea for speed of operation. Logically, think of limiting as if to say that schemas or tables that are not included do not exist. For more help, run
help limitin the SchemaCrawler interactive shell, or
-h limitfrom the command-line.
- grep: Search for metadata using regular expression. You can search for regular expressions using column names or search within column definitions. This is an optional step. For more help, run
help grepin the SchemaCrawler interactive shell, or
-h grepfrom the command-line.
- filter: Filters table based on foreign key relationships, also called parent-child relationships. You can filter to any number of generations. This is an optional step. For more help, run
help filterin the SchemaCrawler interactive shell, or
-h filterfrom the command-line.
- load: Loads the database schema metadata into memory. If you change any of the limit, grep, or filter options, you will need to load database schema metadata again in the SchemaCrawler interactive shell. This is because during the load process, SchemaCrawler eliminates any tables that are not matched by limit, grep, or filter operations. The load command uses multiple catalog loaders, which run sequentially. You provide options for these loaders with the
loadcommand. For more help, run
help loadin the SchemaCrawler interactive shell, or
-h loadfrom the command-line. To get a list of all available commands, run
help loaders, or
-h loadersfrom the command-line. To get specific help for a database plugin, run a command similar to
help loader:weakassociationsloader, or
- execute: Executes a SchemaCrawler command, including commands to generate diagrams. Numerous commands are available, and more can be plugged-in. For more help, run
help executein the SchemaCrawler interactive shell, or
-h executefrom the command-line. To get a list of all available commands, run
help commands, or
-h commandsfrom the command-line. To get specific help for a database plugin, run a command similar to
help command:schema, or
The Katacoda tutorial on the interactive shell walks you through these concepts to help you understand them.