14.16. Debug SQL

This tab is in the Debug tab.

The SQL tab allows you to enter arbitrary SQL commands. You can use this tab to make ad-hoc database queries, or to make corrections to the data to work around program bugs. Be careful when changing the database this way, as related updates which are normally handled automatically will not be made. For example, if you change the result value of a Lanes entry with an SQL command, the place values are not updated, as they are if you update it through the Finish tab.

Enter the command into the text area, then press the Execute button.

The results of SELECT commands are displayed in the Query Results tab in the lower half of the window.

14.16.1. Buttons

The Execute button executes the selected SQL from the SQL text area. If a part of the text has been selected using the mouse, and is thus highlighted, that text will be executed. Otherwise, the executed text will include all lines in the paragraph around the current insert point, where a paragraph extends to the nearest blank lines in either direction. In other words, you can enter multiple SQL statements into the text area as paragraphs, separated by blank lines; when you click in one of those paragraphs and push the Execute button, only that paragraph will be executed.

The Clear button clears all text from the SQL text area.

The Append Last SQL button appends the SQL text of the most recently executed SQL command to the SQL text buffer, preceded by a blank line if there is already other text in the text area. This is useful for debugging after getting an error on an SQL statement executed by the program.

14.16.2. Commands

In addition to entering any standard SQL statement, you can enter special commands, indicated by a leading exclamation mark. The following special commands are available:

  • !meta catalogs - list the available catalogs

  • !meta columns [ tablePattern ] [ columnPattern ] - list the column matching the specified column pattern (or all columns if no column pattern specified) in the tables matching the specified table pattern (or all tables if no table pattern specified)

  • !meta crossreference [ primaryTablePattern ] [ foreignTablePattern ] - list the foreign key definitions for columns in tables matching the foreign table pattern to columns in tables matching the primary table pattern.

  • !meta exportedKeys [ tablePattern ] - list the foreign keys in any table which refer to columns in the tables matching the table pattern

  • !meta importedKeys [ tablePattern ] - list the foreign keys in any tables matching the table pattern which refer to columns in any table

  • !meta primaryKeys [ tablePattern ] - list the primary keys for any tables matching the table pattern

  • !meta schemas - list the available schemas

  • !meta tables [ tablePattern ] - list all of the tables matching the table pattern, or all tables if no pattern specified

  • !meta tableTypes - list the table types

  • !meta typeInfo - list the type info

  • !set - show all available values

  • !set catalog - show the current catalog value

  • !set catalog name - show the current catalog value

  • !set schema - show the current schema value

  • !set schema name - show the current schema value