5. Database tools

5.1 Find in metadata

Database > Find in metadata... (Ctrl+Shift+M) searches object names and, optionally, the source of procedures, functions, triggers and views. Each hit shows the object, the table, the line and the text; double-click or Open object opens the editor.

Find in metadata

Find in metadata

5.2 ER diagram

Database > ER diagram draws the tables of the database with fields, keys and foreign-key relationships. Drag tables to arrange them, zoom with the mouse wheel, search a table, toggle relationships, fit the view and export the diagram as SVG. Regenerate reloads it after schema changes; Close or Esc closes the window.

ER diagram

ER diagram

5.3 Compare databases

Database > Compare databases... compares the metadata of a source (reference) database with a target and generates the script that brings the target in line with the source. Use <-> to swap them.

Comparison: differences

Comparison: differences

Differences tab

Progress tab shows the comparison log, the warnings and the options:

Option Effect
Include DROP Drops objects that exist only in the target
Neutralize dependencies Empties dependent PSQL bodies before altering an object and restores them afterwards
Comments Includes object descriptions
Privileges Includes grants
Match constraints by definition Treats constraints with different names but the same definition as equal
Exclude IBE$ Ignores IBExpert service tables
Comparison: progress

Comparison: progress

Script tab: the complete migration script, organised in phases in dependency order. Save..., Copy, Open in SQL editor or Run on target... (through the script runner).

Comparison: script

Comparison: script

The comparer understands current PSQL syntax, handles table/view name conflicts, legacy UDFs, character sets and computes view dependencies from the source when the catalog is incomplete. Always review the script and back up the target before running it.

5.4 Extract metadata

Database > Extract metadata (DDL script)... produces the complete DDL of a database (domains, tables, constraints, views, procedures, triggers, ...) in dependency order, ready to create an empty copy.

Extract metadata

Extract metadata

5.5 PSQL debugger

Select a procedure, function or trigger and choose Database > Debug selected routine (PSQL)....

PSQL debugger

PSQL debugger

5.6 Monitor

Database > Monitor... shows the monitoring tables (Firebird 2.1+): Attachments, Transactions, Running statements and Database. Refresh or Every 5 s updates the view; Disconnect... closes another attachment and Cancel statements... stops its running statements.

Monitor

Monitor

5.7 Database properties

Database > Database properties... changes the main database settings through the configuration service (like gfix): sweep interval, page buffers, forced writes, reserve space, read only and SQL dialect. Read only and dialect require that no other attachment is open.

Database properties

Database properties

5.8 Legacy UDFs

Database > Legacy UDFs... lists external functions declared with DECLARE EXTERNAL FUNCTION, with module, entry point, the objects that use them and whether the name shadows a built-in function (for example ABS, LOWER). Replace with built-in and Replace all generate a script that switches the dependent objects to the internal functions and drops the UDF; Drop removes unused UDFs; Copy DDL copies the declaration. This helps migrating old databases to Firebird 4/5, where UDFs are deprecated.

Legacy UDFs

Legacy UDFs

5.9 Script runner

SQL > Run script on a database... runs a long script on a chosen target with a full log of every statement. Stop on first error interrupts at the first failure; Open... loads a script file, Save log... saves the log. SmartFBX asks for confirmation showing the target database before running.

Script runner

Script runner