Extracting Metadata - Firebird

From the command line, you can use the –extract option to output the DDL statements that define the metadata for a database.

All reserved words and objects are extracted into the file in uppercase unless the local language uses a character set that has no uppercase. The output script is created with commit following each set of commands, so that tables can be referenced in subsequent definitions. The output file includes the name of the object and the owner, if one is defined.

The optional –output flag reroutes output to a named file.

Use this syntax:

isql [[-extract | -x][-a] [[-output | -o] outputfile]] database

The –x option can be used as an abbreviation for –extract. The –a flag directs isql to extract all database objects. Note that the output file specification, outputfile , must be a fully qualified path and follow the –output flag. The path and name of the database being extracted can be at the end of the command.

You can use the resulting text file to

  • Examine the current state of a database’s system tables before planning alterations. This is especially useful when the database has changed significantly since its creation.
  • Create a database with schema definitions that are identical to the extracted database.
  • Open in your text editor to make changes to the database definition or create a new database source file.

Using isql –extract

The following statement extracts the SQL schema from the database employee.fdb to a schema script file called employee.sql:

isql -extract -output /data/scripts/employee.sql /data/employee.fdb

This command is equivalent:

isql -x -output /data/scripts/employee.sql /data/employee.fdb

These objects and items are not extracted:

  • System tables and views, system triggers
  • External function and BLOB filter code (it’s not part of the database)
  • Object ownership attributes

Using isql –a

The –(e)x(tract) option extracts metadata for SQL objects only. If you wish to extract a schema script that includes declarations, such as DECLARE EXTERNAL FUNCTION and DECLARE FILTER, use the –a option.

For example, to extract DDL statements from database employee.fdb and store in the file employee.sql, enter

isql -a -output /data/scripts/employee.sql /data/employee.fdb

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Firebird Topics