Forward engineering & SQL scripts

When it comes to forward engineering in Luna Modeler, it’s about generating the resulting script for the selected target platform. In the case of relational databases such as Oracle Database, SQL Server, PostgreSQL, MariaDB, MySQL or SQLite, it is the resulting SQL script.

How to generate the SQL script?

To generate a script from your project click the SQL Script icon on the main toolbar.

Generated SQL Script for Oracle Database. The script was generated by Luna Modeler

The preview of the script appears in a modal form. Click Save Script and select a location where the file(s) should be stored. Option Overwrite existing files allows you to ignore existing scripts and overwrite them without getting a warning.

Generation settings

You can control how the script will be generated on the Generation settings tab

Generation settings for Oracle Database projects created in Luna Modeler.

Order items

The order of objects can be changed on the Order Items tab. We plan to improve this functionality in future versions and make it more user-friendly, however, even in this version it is possible to move the selected object higher or lower using drag and drop.

It is also possible to automatically reorder objects by clicking the Reset order button, when dependencies are analyzed and items are automatically reordered.

Order of items. See how to easily sort objects for SQL Script generation for Oracle Database.

Script and templates

On tab Script and Templates additional code from your project can be generated.

Script and templates in Luna Modeler.

You can write your own templates and generate custom output. For details, see Custom Templates & Scripts

Settings for Auto-generated scripts and Custom code

If you have a table in progress and do not want to generate the resulting script for it, turn off the Include table in generated script option. And if you need to generate other code, you can enter it in the Custom Code field and use Include custom code in generated script switch below that field. This way you can get better control over the generated script for the entire data model or diagram.

Settings for Auto-generated scripts and Custom code

Before and After Script

Project level

If you want to run any script before executing SQL code generated from Luna Modeler, you can enter it in the project properties, in the Before script section. Similarly, you can write a script that will be placed at the end of the generated SQL.

Before and After script sections in Project Properties in Luna Modeler.

Object level

The Before Script and After Script sections are also available for objects such as tables. Here, too, you can enter code to be placed at the end of the script valid for the table. This can be a partition or, for example, INSERT statements.

Before and After script sections in Table Properties in Luna Modeler.

Tip: Insert statements can also be specified as Custom Code in Other objects and displayed in a diagram.

Other object with INSERT statements in a data model created in Luna Modeler.

How to run the generated SQL script?

You will need another tool to execute the generated SQL scripts. Luna Modeler is a tool for data modeling and report creation. For now, it is used exclusively for data modeling.

DATA MODELING TOOLS
DRAW Diagrams and
GENERATE Scripts
Download data modeling tools
Blog Categories
Blog by Platforms