Generate DDL for a Package

When you have defined a package in your database model, you can generate DDL for that package, and also compare the DDL with the database.

Access    Project Browser package context menu | Code Engineering | Generate DDL, or
                 Select package   Tools | Database Engineering | Generate Package DDL

Generate DDL for a package

Step

Action

See also

1

On the Generate Package DDL dialog, select the checkbox against each inclusion required.

Deselect the checkboxes for inclusions you do not require.

 

 

2

To recursively generate DDL, select the Include All Child Packages checkbox.

 

 

3

Select the Save Generated Order checkbox to save the order in which the objects are generated.

This is useful where the order is changed to resolve object dependencies; the order is saved when you click on the Generate button.

 

 

4

If you click the Refresh button with the Save Generated Order checkbox unchecked, the objects are restored to their original order.

 

 

5

Click on the Generate button to proceed.

Enterprise Architect prompts you for file names as the process executes.

 

 

6

To view the output, click on the View button.

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

 

Compare the generated DDL with the database

Step

Action

See also

1

On the Generate Package DDL dialog, click on the Compare button.

The Compare With Database dialog displays.

 

 

2

Click on the Browse (  ...  ) button and locate the required database on the Select Data Source dialog.

 

 

3

For an Oracle database, if required you can also specify the Owner in the Schema/Owner field.

Set up an Oracle ODBC Driver

 

4

Click on the OK button to perform the comparison.

The Comparison Database dialog displays with the results of the comparison.

Click on each table name to review information on that table.

 

 

5

Click on the:

Save button to save the altered DDL statements to a file
View button to open the saved file in a text editor
Copy button to copy the altered DDL statements to the clipboard

 

 

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
Some checkboxes display only if the appropriate database is defined for the table; for example, IF EXISTS displays only if the database for the table is PostgreSQL, and SEQ_ and _SEQ radio buttons display only if the database for the table is Oracle
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 - this ensures 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 generating Oracle sequences, to generate the sequence name and trigger name with  the syntax SEQ_<sequence_name>  and TRG_<trigger_name>, select the SEQ_ option; conversely, to generate them with the syntax <sequence_name>_SEQ and SET_<trigger_name>, select the _SEQ option
 

Learn more