Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Generate DDL For an Object

As you create your database model, you can generate the DDL for an individual object (generally a Table) to check the definition of that object. You set the parameters for generation on three separate tabs of the Generate DDL dialog.

Access     On diagram | Right-click on object element | Generate DDL
Tools | Database Builder | Right-click on object element | Generate DDL

Generate Tab



See also

Single File

If you want to store the script in a file, select this radio button and type in or browse for (click on the DDLPackBrowse button) the file path and name under which to create the script.



Generate to DDL Execution Engine

(The default selection.) Generates the DDL to the Execute DDL tab of the Database Builder, opening the Database Builder at that tab if it is not already displayed.

The DDL Execution Engine provides the facilities for executing the generated SQL script and responding to errors in execution immediately, without having to create an external file and load it into another tool.



Generate and Execute DDL


After you have defined the generation parameters on the Options and Format tabs, click on this button to create the DDL.




If you have generated the DDL to an external file, click on this button to view the output.

The viewer defaults to the Enterprise Architect default code editor. However, you can define an alternative default DDL editor on the Options dialog (Tools | Options | Source Code Engineering | Code Editors).


Editing Source Code

Options - Code Editors


Click on this button to close the dialog. If you did not generate the DDL, this button also abandons DDL generation for the object.



Options Tab



See also

Option Checkboxes

Select the checkbox for each type of object associated with the selected object that you want to include in the DDL generation.

Deselect the checkboxes for inclusions you do not require.



Format Tab



See also

Comment Level

To include comments in the DDL, click on the drop-down arrow and select the appropriate level.

For example, select Column to include comments on columns, or All to include comments on all structures.



Create Drop SQL


Select the checkbox if you want to include a 'drop Table' command for each Table in the script.



Select the checkbox to include IF EXIST statements in the generated DDL if the current DBMS supports them.



Use Database

Select the checkbox and type in the name of the database, to include the keywords Use {database} at the beginning of the generated DDL so that the DBMS executes all the statements against the specified database.



Use Alias if Available

Select the checkbox to use object Aliases instead of the object names, where such Aliases are specified.



Use NULL for nullable columns

Select the checkbox to set columns that are not set to NOT NULL to specifically have the keyword NULL defined against them in the generated DDL, if the DBMS supports this.



Separate constraint definition from table definition

Select the checkbox to define constraints (such as Primary Keys, Foreign Keys and Unique Constraints) in their own ALTER TABLE statements rather than within the CREATE TABLE statement in the DDL.




·In the Corporate, Business and Software Engineering, System Engineering and Ultimate editions of Enterprise Architect, if security is enabled you must have Generate Source Code and DDL permission to generate DDL
·For a PostgreSQL database, you must select the Generate Sequences checkbox to enable auto increment columns to be created
·If generating Oracle sequences, you must always select the Generate Triggers and Generate Sequences checkboxes, so that a pre-insert trigger is generated to select the next sequence value to populate the column; also set the AutoNum property to True in the column properties
·If you have the appropriate knowledge and expertise, you can edit the DDL templates that the system uses to generate the DDL


Learn more