Import SQL / DDL

DbSchema can import a design model from external files — including CSV, Excel, and SQL DDL files containing CREATE TABLE statements. After import, the schema is displayed as a visual diagram and saved to a .dbs model file.

Import model from external file

Importing from a File

Open the importer via Model → Load From External Format. A file picker lets you select the source file.

Choose file to import

After selecting the file, map each column in the input data to its role in the schema:

  • Schema — the schema/database name
  • Table — the table name
  • Column — the column name
  • Type — the data type
  • Length — the column length or precision
  • Nullable — whether the column allows nulls
Map columns to schema, table, column, type and length

DbSchema loads the data into an internal H2 database, parses it, and generates a new design model with the inferred tables and columns.

Configurable Model Exporters

Access the export dialog from Model → Export As…. You can define a custom exporter with:

  • Operations — iterate over tables, columns, foreign keys, or indexes.
  • Filters — conditions that must be met before a field is included (e.g. skip nullable columns).
  • Fields — the values to export for each iterated object.
  • Patterns — a text template where ${value} is replaced with the actual field value. Patterns let you produce comma-separated files, tab-delimited files, XML, or any other text format.

Patterns can be set globally for the entire exporter, per tab/section, or per individual field.

Export via Groovy Script

For maximum flexibility, export the design model using a Groovy script in the Automation Scripts dialog (Tools → Automation Scripts).

The built-in Model to CSV File example script is a good starting point. Copy it, paste it into an SQL Editor, switch the language from SQL to Java Groovy, and customise it to export exactly the fields you need.

Groovy is 100% compatible with Java, so any Java knowledge applies directly. The full DbSchema API is linked from the Automation Scripts dialog and documented at DbSchema API.