Skip to content

Import from and apply to a database ​

Bring the structure of an existing database into a model, and apply a model to a database.

Import from a database ​

  1. Open File › Import › From DB.
  2. Enter the connection details and connect. The drivers for PostgreSQL, MySQL, MariaDB, SQL Server and SQLite are built into the app, so there is nothing else to install.
  3. Choose the schemas to import.
  4. Choose the tables, views, sequences and triggers and add them to the document. The whole import is undone with a single Ctrl+Z.
Import from DB — choosing the objects to import
Import from DB — choosing the objects to import

Apply to a database ​

  • Creating it for the first time — File › Export to DB… (also on the toolbar). The SQL to run is shown first; on databases that support it, everything runs in one transaction and is rolled back if a statement fails.
  • Applying only the changes — Generate migration SQL (ALTER) from the differences between the model and the database structure.
    1. In a new diagram, use Import from DB to bring in the current database structure, and save it as a file (for example db-now.erm).
    2. Open the model you want to apply and choose that file in File › Compare and merge › Compare with another file….
    3. In the comparison view, choose Export ▾ › Generate migration SQL (PostgreSQL, MySQL, MariaDB, SQL Server, Oracle).
    4. Check the warnings about risky changes and the "Manual step required" list, then run the SQL yourself in your database tool. Relio never runs this SQL.
Migration SQL generated from the comparison view
Migration SQL generated from the comparison view

Warning

Always read the SQL before running it on a real database, and back up production databases first.

For Oracle, prepare the Oracle Instant Client folder first; for Db2, Informix and MS Access, the ODBC driver. H2 and HSQLDB cannot be connected to directly, so export a DDL file and run it. Database passwords are stored in the Windows Credential Manager by default.

More → Databases · Git and merging › Generating migration SQL · Help and troubleshooting

Relio is a separate tool, not affiliated with ERMaster.