v0.9.2 Summary Chapter 2: Modeling basics 2. Start modeling 2.6. Custom SQL commands

2.6. Custom SQL commands

In order to provide more flexibility when generating SQL code for database objects pgModeler implements a special dialog used to append and prepend arbitrary DML or DDL commands. This is useful, for instance, when you need to populate tables using INSERT commands right after creating them or execute some specific operations before or after creating objects.

Not only INSERT commands are possible to be included but any sort of commands accepted by PostgreSQL, even complete object definitions can be used. This as a great feature but, on the other hand, can cause an unnecessary file bloating in case of an excessive amount of code is appended or prepended to objects since any command written in the custom SQL dialog is saved into the database model file, so use this feature wisely and with extreme caution.

This dialog offers command templates for SELECT, INSERT, UPDATE and DELETE in order to speed up the productivity preventing the user to type the entire commands. When adding commands to the database object there is an additional option which enables the commands to be added at the very end of the database model SQL definition instead of the end of the database definition itself. By the same analogy, you can insert commands at the top of database model's definition when prepending SQL commands to it.

Finally, the command template buttons includes additional options when the user is adding commands to table's definition. Those buttons are able to create SQL templates that considers the existent columns of the table. Be in mind that the custom SQL commands are validated only when the SQL validation process is executed. Be careful when using DROP or UPDATE statemens since pgModeler will execute them without restrictions.


Jan 3, 2020 at 12:33