Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.
Generate DDL For a Package
As you create your database model, you can generate the DDL for the whole model (underneath the root node) or for a specific Package in the model. However, if you have created your model using one of the Database Engineering model patterns, the DDL Generator automatically selects the <<Database>> stereotyped Package.
You set the parameters for generation on three separate pages of the Generate DDL dialog.
Access Project Browser | Right-click on Package | Code Engineering | Generate DDL, or
Click on Package | Package | Database Engineering | Generate Package DDL
Tools | Database Builder | Right-click on Package | Generate DDL
Generate Page
Field/Option/Button |
Action |
See also |
||||||||
---|---|---|---|---|---|---|---|---|---|---|
Package |
Displays the name of the selected Package. If this is not the Package for which you want to generate DDL, click on the
|
|
||||||||
Include All Child Packages
|
Select this checkbox to generate DDL from the child Package structure of the selected Package. |
|
||||||||
Delete Target Files |
If, in the Select Objects to Generate panel, there are files listed in the Target File column and you want to create new files rather than update the existing files, click on this button. The files are deleted and removed from the list.
|
|
||||||||
Select Objects to Generate |
The order in which the objects are listed is the order on which DDL is generated from them. If you need to change this order to resolve object dependencies, click on an object to move and click on the
Select each object for which to generate DDL. Click on:
|
|
||||||||
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 |
Click on this button to reverse changes to the order of the objects.
|
|
||||||||
Single File |
If you want to store the complete script in one file, select this radio button and type in or browse for (click on the
|
|
||||||||
Individual file for each table |
If you want to save the DDL generated for each object to a separate file, select this radio button. When you click on the Generate button, the system prompts you for the target file name for each object in turn.
|
|
||||||||
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 |
After you have defined the generation parameters on the Options and Format tabs, click on this button to create the DDL.
|
|
||||||||
View |
If you have generated the DDL to a single 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).
|
|||||||||
Close |
Click on this button to close the dialog. If you did not generate the DDL, this button also abandons DDL generation for the Package.
|
|
Options Page
Field/Option/Button |
Action |
See also |
---|---|---|
Option Checkboxes |
Select the checkbox for each type of object associated with the Tables that you want to include in the DDL generation. Deselect the checkboxes for inclusions you do not require.
|
|
Format Page
Field/Option/Button |
Action |
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 'drop Table' commands in the script. |
|
IF EXISTS |
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.
|
|
Notes
· | 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 |
Learn more