Back to articles list
- 3 minutes read

How to Generate a SQL Script in Vertabelo?

Find out how to generate a SQL DDL script using Vertabelo and what this script does.

You probably already know what ER diagrams are. If you're not sure, you can find out here. You can create ERDs easily in Vertabelo. But did you know that Vertabelo can also generate a SQL DDL script from your physical ER diagram?

Of course,  you first need to create a physical diagram. Once your ER diagram is ready, you can create a DDL (Data Definition Language) script. You need a SQL DDL script to create tables, views, and references in the physical database. Vertabelo can automatically generate a script that creates or removes tables or references. You don’t have to remember the syntax details of your database and write the script from scratch.

Create a DDL Script in 3 Simple Steps

1. Create a Physical Diagram.

You can first create a logical diagram and then use it to generate a physical diagram, or you can just go straight to a physical diagram. If you're not sure how to create an ERD, this article will help you. Here's a simple example of what you’d see in a physical ER diagram:

Generate SQL Script

2. Click the “Generate SQL Script” button.

On the Vertabelo modeling tool’s upper panel, you'll find the "Generate SQL Script" button. Click it and you'll see this:

Generate SQL Script

Choose whether the script should create or drop the selected objects and what objects you want to include. The DDL script Vertabelo generates can create or drop tables, references, sequences, views, procedures, or only the selected objects. You decide!

Also, you may want to create this code for only some elements of your database. Just select your desired items (e.g. the school table) before you click “Generate SQL Script” and check the “Only selected elements” option before clicking the "Generate" button. This way, you'll create only the code for that/those item(s).

The SQL DDL script will use the same syntax as the database engine your physical data model uses.

3. Click “Generate.”

When you've decided what elements you'd like to create/drop, you can generate a script. It’s as easy as clicking the "Generate" button. Here's what you'll see:

Generate SQL Script

Name the script and save it in Vertabelo so that you can access it later. Once you've saved the generated file, the "Save" button changes to "Open". You can click on it to see your script. It contains the date and time of the last modification and the SQL code with comments. The tables, sequences, keys, constraints, etc. are created/dropped for you in no time!

If you decide to change something, you can edit the code or modify the diagram and generate a new SQL DDL script.

Of course, you can also download the script and run it against your database.

See? It's easy! Try it out yourself. :)

go to top

Our website uses cookies. By using this website, you agree to their use in accordance with the browser settings. You can modify your browser settings on your own. For more information see our Privacy Policy.