Copying SQL Statements from Entities in ERD

Visual Paradigm provides function of copying SQL statements from entities in ERD. It provides you with a handy approach to copy the SQL statements you need in creating, altering and deleting data in database. By copying the SQL statements you can make necessary change to the statements and then execute them in your database.

Note that in order to use this function, you must configure the database setting in advance as Visual Paradigm will generate the SQL statements according to the default DBMS selected.

Copying SQL statements for all entities in ERD

  1. Right click on the background of an ERD and select Utilities > Generate SQL... from the popup menu.
  2. In the Generate SQL window, you can copy the DDL statements (Create/Drop/Alter) or DML statements (Select/Insert/Update/Delete). If you have configured multiple DBMS, select the desired DBMS from the Database drop down menu. The corresponding SQL statements will be displayed accordingly.
    Generate SQL window
    Generate SQL window

    The Generate SQL window also provides you with several configuration options to the statements.
    Option Description
    Delimiter Delimiter of each SQL statement. Use \n to represent line break, \\n to represent '\n'.
    Case Force the content of the generated DDL to be in upper or lower case.
    Formatted SQL
    Apply proper line breaking and indentation to make the statements formatted prettier.
    With constraint Let's say, for example if entity X has a FK that references entity Y, if you only selected to generate SQL for entity X, with this option checked, alter statements will also generated for adding the necessary constraint to entity Y.
    Include Comment Generate entity and column description as comments of tables and their columns. (Only available to My SQL, DB2, Oracle, Postgre SQL)

    Configuration options

    Besides copying SQL statements, you can execute them directly from the Generate SQL window by clicking  above the statements.

Copying SQL statements from a selected scope

An ERD may be large and contains many entities, or even all entities of your database. Sometimes, you may want to get SQL statements from only some of the entities in an ERD, but not all. Visual Paradigm provide you with two options:

Some entities in an ERD

Select the entities and relationships on the ERD. Right click on the selection and select Generate SQL... from the popup menu. In the Generate SQL window the DDL and DML statements of the chosen entities and relationships are presented.

Relationship(s) in an ERD

If you want to obtain the SQL statements for creating or dropping constraints, choose this option. Select the desired relationships. Right click on them and select Generate SQL... from the popup menu.

Related Resources

The following resources may help you to learn more about the topic discussed in this page.

 
4. Patching Design Changes to Database Table of Contents Chapter 4. Programming Guides

We use cookies to offer you a better experience. By visiting our website, you agree to the use of cookies as described in our Cookie Policy.OK