DbConsole
Author: Dale Anson
Version: 2.0.1
Command Reference
Invariably, I add new features and don't get the documentation up-to-date. Check the current command list by using the \? command in DbConsole. All application and meta-commands are case-insensitive, that is, \ls and \LS will do the same thing.
Application Commands
Application commands start with \:
- \copyright displays the copyright for DbConsole
- \intro to display the application introduction
- \? or \h or \help for help
- \v to display the version
- \config edit database configurations.
- \dbinfo for information about the current database
- \exportconfig export one or all configurations to a file. This command will save existing database configurations to a file so that you can import the configurations into DbConsole running on another machine.
- \importconfig import database configurations from a file. Configuration files must be in the format produced by \exportconfig. Importing a configuration file does not remove configurations, but will modify existing configurations with the same name.
- \q to quit
Meta-Commands
Meta-commands also start with \. Items in {} are required, in [] are optional:
- \r Reset (clear) the query buffer. This lets you start a new command without executing whatever may already be in the buffer.
- \autocommit Toggle autocommit mode. By default, all connections have autocommit turned on, so you don't have to explicitly commit. This lets you temporarily turn off autocommit.
- \commit Perform a commit. Only useful when autocommit is off.
- \rr Rerun previous command.
- \sh Show saved queries. You can pick a query from the history list and run it again.
- \s Stop the current running command. This lets you stop a long running query without stopping DbConsole. Partial results may be displayed. This doesn't work most of the time.
- \color Toggle color output. Color output works well on Linux and Solaris, iffy on Windows. I don't have a Mac, so any comments about it would be welcome. With color on, the row number of result sets, column names, and column separators will be in a different color, which makes the table output easier to read. If it doesn't work on your particular platform, you'll see a lot of garbage in your result sets (all the ASCII color codes will be shown as text rather than color), so just turn off the color. If you're using cygwin on Windows, you can try piping the output to 'cat', like this:
java -jar DbConsole_2.0.1 | cat
That trick works for me on Win2k anyway, but you'll lose the ability to 'arrow up' for the command history in your shell. On the other hand, you can use the \sh command to rerun a query. - \db change database
- \o [o] {filename} Write query output to filename. if the 'o' option is present, the file will be overwritten, otherwise, it will be appended to. So \o o myoutput.txt will cause the contents of myoutput.txt to be overwritten.
- \i {filename} Read SQL queries from filename and execute them.
- \ls List the schemas in the current database.
- \lt [schemaname [[.]tablepattern]] List the tables in the current database. Use with a specific schema name to just list the tables in that schema, or use a table pattern to list only a subset of tables. A table pattern uses the % symbol for a pattern, for example, you might use \lt COMPANY_INFO.EMPLOY% to list all tables in the COMPANY_INFO schema that start with EMPLOY, so tables like EMPLOYEES, EMPLOYEE_TIME_OFF, and so on would be listed. Depending on your database the schema name and table names maybe case sensitive.
- \ltp [schemaname [[.]tablepattern]] List the privileges for some tables. See the \lt command above for the details on the schema name and table pattern. Depending on the permissions granted your user, this may not return any information.
- \lc [schemaname[.]] tablepattern List the columns in a table. See the \lt command above for the details on the schema name and table pattern. This is a fairly terse output, but is generally enough for casual inspection of the columns of a table. See the \dt command below for a very detailed table description.
- \lp [catalog] [schemapattern[.]] procedurepattern List the procedures for a schema. Both the schema and procedure names may use a pattern like that described in the \lt command above.
- \dt [schemaname [[.]tablepattern [[.]columnpattern]]] Describe one or more tables and/or specific columns within those tables. See the \lt command above for the details on the schema name and table pattern. The columns may be specified with a similar pattern.
- \sdc [catalog] Set the default catalog name. If a name is set, this name will be used as the catalog for the \l* commands that take a catalog name.
- \sds [schema] Set the default schema name. If a name is set, this name will be used as the schema for the \l* commands that take a schema name.
- \sr [row] Show the data for a specific row. If row is omitted, show the data for the first row. Some queries may return a lot of columns, and screen width may cause the rows to wrap, making it hard to read the data. This command will show a single row in a two-column format, with the left column showing the column names, and the right column showing the data for that row. This can be a lot easier to read.
- \sh Show query history. A query can be selected from the displayed list to run again.
- \shs Set the size of the query history. Defaults to 20. Depending on your environment and the size of the queries, this number may need to be set smaller to fit on the screen.
- \sw Set the width of the messages boxes for display. Defaults to 60 characters, set wider for wider screens.
- \land Toggle "landscape" mode. This works like the \sr command, but shows all output rotated 90 degrees to the left, that is, the column names will be shown in the first column, all other rows will be shown in the columns to the right. This can be a lot easier to read in those cases where only a few rows are returned but the rows are wide. This doesn't work so well when a lot of rows are returned and the output wraps.
As of version 2.0, DbConsole uses the excellent jline library to assist with command input. This library provides command history across all platforms, which has been a problem with DbConsole in the past. Those familiar with the 'bash' shell (or other Unix shells providing history) will recognize the value of this right away. You can use the 'up' and 'down' arrows to select a previous command to run and/or edit.
A word about case and the meta-commands: Some databases are sensitive about case. I tend to type everything in lowercase, but that doesn't always work on all databases. For example, Oracle would accept a command like \ls EMPLOYEES but would reject \ls employees. DbConsole first tries to execute the command exactly as it is entered, if that doesn't return any results, it will try again with everything in upper case.