Prev Next

Generate DDL For Objects

As you create your database model, you can generate the DDL for an individual object, a Package of objects or the complete data model. The only difference is how you invoke the generate DDL process.

Access

Open the Database Builder window, then use the context menu and select 'Generate DDL'.

Ribbon

Specialize > Tools > Database Builder > Right-click on an object, Package or Data Model node > Generate DDL

Code > Schema > DDL > Open Database Builder > Right-click on an object, Package or Data Model node > Generate DDL

Generate Tab

Field/Button

Action

See also

Package

Click on the button and browse for the Package for which you want to generate DDL, using the Navigator window (a version of the 'Find Package' dialog).

(Note: This field might not be displayed in all situations.)

Include All Child Packages

Select this checkbox to include the objects in sub-Packages in the 'Select Objects to Generate' list.

Delete Target Files

When objects are generated to single files, the full filename is stored with the object, and displayed in the 'Target File' column of the 'Select Objects to Generate' list.  

Click on this button to remove all the existing filenames and prompt for new ones.

Select Objects to Generate

This field displays the list of objects that DDL will be generated for, in the displayed order. If you need to change this order to resolve object dependencies, click on an object to move and click on the buttons to move that object one position up or down in the sequence.

Select each object for which to generate DDL. Click on:

  • The All button to select every item
  • The None button to clear all selections
  • Each of several objects while you press Ctrl, to select a number of individual objects
  • The first and last objects in a block while you press Shift, to select every object in the block

Save Generated Order

If you have changed the order in which the objects are listed, select the checkbox to save the new sequence when you click on the Generate button.

Refresh

Reload the list of objects, restoring each object to their previous positions (if object positions have been changed).

Single File

Select this radio button if you want to save the generated DDL to a single file.

Click on the button to browse for the file path and file name.

Individual file for each table

Select this radio button if you want to save the DDL generated for each object to a separate file.

When you click on the Generate button, the system prompts you for the target file name for each object in turn (if it is not specified already).

Generate to DDL Execution Engine

Select this radio button if you want to save the DDL to the execution engine (the 'Execute DDL' tab of the Database Builder).

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 to DDL Execution Engine' is the default option if the Database Builder is open.

Generate and Execute DDL

Generate

Click on this button to run the Generate DDL process with the options you have selected.

View

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

By default Enterprise Architect uses the default code editor. However, you can define an alternative default DDL editor on the 'Preferences' dialog ('Start > View > Preferences > Source Code Engineering > Code Editors > DDL').

Data Modeling Settings

Close

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

Set any of these flags to False if you do not want to take the action they initiate.

Group

Options

Table Generation Options

Tables - indicates that DDL for Table elements should be generated (*)

Primary keys - indicates that DDL for Primary Keys should be generated ($)

Foreign Keys - indicates that DDL for Foreign Keys should be generated ($)

Indexes - indicates that DDL for Indexes should be generated ($)

Unique Constraints - indicates that DDL for Unique Constraints should be generated ($)

Check Constraints - indicates that DDL for Check Constraints should be generated ($)

Table Triggers - indicates that DDL for Table Triggers should be generated ($)

Table properties - indicates that DDL for extended table properties should be generated ($)

Length Semantics - indicates that DDL for Oracle Length Semantic should be generated ($)

Object Generation Options

Views - indicates that DDL for View elements should be generated (*)

Procedures - indicates that DDL for Procedure elements should be generated (*)

Functions - indicates that DDL for Function elements should be generated (*)

Sequences - indicates that DDL for Sequence elements should be generated (*)

Packages - indicates that DDL for Oracle Packages elements should be generated (*)

Formatting

Include pre/post queries - indicates that the generated DDL should include the SQL statements defined in the '_PreStatements' and '_PostStatements' SQL Queries

Include Owners - indicates that the generated DDL should include the schema/owner of all elements

Include Comments - indicates that the generated DDL should include any comments

Include Header Comments - indicates that the generated DDL should include any header comments (#)

Include Object Comments - indicates that the generated DDL should include any object (such as Table or View) comments (#)

Include Column Comments - indicates that the generated DDL should include any columns comments (#)

Generate DROP statements - indicates that the generated DDL should include the DROP statement for objects

Use Database - indicates that the generated DDL should include a USE Database statement

Use Alias - indicates that the generated DDL makes use of any object or column aliases

Separate Constraint from Table - indicates that the generated DDL should define the creation of constraints as separate statements from the Table definition

Include NULL in column definitions - indicates that the generated DDL should apply the NULL keyword to each column definition that is defined as nullable; that is, columns with their 'NOT NULL' flag unchecked (this option only applies to the DBMSs that support the 'NULL' syntax)

Notes

  • (*) - options with this mark will be automatically set to True if you have specified to generate DDL for an individual element of that type; that is, if you select a Table and your 'Generate Table' option is False, Enterprise Architect will change the option to True
  • ($) - options with this mark will be disabled if the 'Tables' option is set to False
  • (#) - options with this mark will be disabled if the 'Include Comments' option is set to False

  • In the Corporate, Unified 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 set the 'Sequences' option to True to enable auto increment columns to be created
  • If generating Oracle sequences, you must always set the 'Table Triggers' and 'Sequences' options to True, so that a pre-insert trigger is generated to select the next sequence value to populate the column; also, in the column properties, set the 'AutoNum' property to True
  • You can edit the DDL templates that the system uses to generate the DDL; these are stored at the repository level so that all other users of the same repository will automatically use the updated templates

Learn more