Firebird – How to Export Database Structure

database-designexportfirebird

I'm doing replication and I need to export db structure from one Firebird db (dialect 3) into another. I've seen a couple tools like IBPump and FBExport, however all I can find is how to export all the data and not the structure. Any advice?

Best Answer

There are several ways to do this:

  1. A metadata-only backup using gbak:

    gbak -backup -meta_data employee employee.meta.fbk
    

    And then restore that backup.

  2. A metadata-only restore using gbak:

    gbak -create employee.fbk mytest.fdb -meta_data
    

    This can be useful if you already have a backup with data.

  3. Exporting the DDL of a database with ISQL (or another tool)

    isql -ex -o ddldump.sql /path/to/your/database.fdb
    

    And then use that script to populate a new database.

For options 1 & 2 see gbak: Backup & Restore Recipes: Meta Data Only
For option 3 see ISQL: Command Line Switches.