Skip to content

DDL ​

The fields of the DDL export dialog, which generates the SQL (DDL) to run on a database from your model, and how syntax and warnings depend on the database version.

The short version is in Generate and export DDL in Quick start.

Where to open it ​

  • File › Export › DDL…
  • Canvas right-click › Document › Export › DDL…
  • Command line relio export ddl — Command line

Supported databases: PostgreSQL · MySQL · MariaDB · Oracle · SQL Server · Db2 · H2 · HSQLDB · SQLite · Informix · MS Access · standard SQL.

Top of the dialog: target and output ​

FieldDescription
Database · Target product · Target versionThe database and version to generate the DDL for. The preview updates as soon as you choose. The target version is remembered per file on this PC, not in the .erm.
EnvironmentThe tablespace environment (Tablespace environments in Model › Options…). Tablespace attributes use this environment's values.
CategoryNarrow the scope to All or a single category.
Output fileWhere to save. Pick it with Browse…. If the file exists, Relio asks before overwriting.
Encoding · Line breakThe character encoding and line ending of the file.
Open the file after savingOpens the file once it is saved.

If you are only previewing another version, the dialog says "Saving changes this document's target version". If you just preview and close, the target version stays as it was.

Statements to generate ​

Turn each kind of statement on or off. Turn all on turns everything on, and Turn off drop statements turns off only the drop statements.

GroupItems
DropDrop indexes · Drop views · Drop triggers · Drop tables · Drop sequences · Drop tablespaces
CreateCreate tablespaces · Create sequences · Create tables · Create foreign keys · Create triggers · Create views · Create indexes

On a fresh database, drop statements can fail with "does not exist" errors. Databases with an existence check syntax use it; for the others, a note is added at the top of the script.

Comments ​

ItemDescription
Generate DB comments (COMMENT etc.)Turns table and column comments into database comment statements.
SQL comment line before objects (-- comment)Adds a -- comment line before tables and other objects.
SQL comment line before columnsAdds comment lines before columns too.
Comment valueWhat goes into the comment — Description · Logical name · Logical name : description
Replace line breaks in comment valuesWhen on, line breaks inside comments are replaced with the Replacement text. Leave it empty to remove the line breaks.

Options ​

ItemDescription
Create with IF NOT EXISTSApplies to tables, indexes and sequences only. On databases without this syntax, the statement is wrapped in an existence check or a warning is shown. To make the script fully re-runnable, use it together with drop statements.
Leave out schema prefixesObjects are created in the connected user's default schema. If the same name exists in another schema, only that name keeps its prefix.
Use Oracle native types (boolean)On Oracle 23 or later, true/false columns are created as boolean instead of number(1,0).
Add SET SQLBLANKLINES ON when comments contain blank linesAdded at the very beginning of the script only when comments contain blank lines, so SQL*Plus does not end a statement at a blank line. When off, it is not added and a warning is shown.
Also drop tablespacesAdds DROP TABLESPACE to the drop statements. This can delete data of other schemas in that tablespace. Drop tablespaces under Statements to generate must also be on.

When you click Save, the environment, category, output file, encoding, line break, Open the file after saving, and the Statements to generate and Comments settings are saved in the document (.erm) and used next time. The target product (MySQL or MariaDB), the target version and the items on the "Options" tab are remembered in this PC's per-file records instead of the .erm. If you only change settings and close without saving, neither is changed.

DDL export dialog — Statements to generate, Comments and Options
DDL export dialog — Statements to generate, Comments and Options

Preview and save ​

  • The Preview in the dialog shows the SQL that will be generated. For large output, line numbers and syntax coloring are turned off.
  • Save writes the file. Click Open folder in the notice at the bottom right of the app window to open the folder in File Explorer with the file selected.
  • The result is reported like "DDL saved (warnings: n — see the problem list)".

Version-specific syntax and warnings ​

  • Syntax that the chosen database version cannot run is removed or changed, with a warning. The dialog shows the number of warnings, and they are also kept in the problem list.
  • Actions the database does not support, such as some ON UPDATE and ON DELETE actions on relationships, are changed to a supported action or left out. The relationship properties dialog tells you in advance.
  • Tables with a column that has no physical name or data type are left out, with the message "n tables left out — a column has no physical name or data type". Double-click the list to see that table on the canvas.
  • If there are design check errors (problems that make the DDL fail when run), the dialog shows "This document has n errors that make the DDL fail", and Show problem list takes you straight there. Ignored errors are not counted. Saving is not blocked.

Tip

If you do not know the version, you can leave it as "version not set". The DDL then uses syntax available from the lowest supported version of that database, so it runs on most versions.

Applying directly to a database ​

Instead of running a DDL file yourself, you can create the model directly in a database with File › Export to DB…. To apply only the changes to an existing database, use Generate migration SQL in the comparison view. Databases · Git and merging › Generating migration SQL

Relio is a separate tool, not affiliated with ERMaster.