Generating DDL for database objects

Use the Generate DDL window to generate DDL, SQL and statistics in a script file to recreate a database objects and its statistics in another database.

Data Definition Language (DDL) is a subset of SQL. It is a language for describing data and its relationships in a database.

There are several reasons to generate DDL, SQL and statistics for database objects.

Note:You can only generate DDL for Version 6 databases.

Fields and controls

Authorities and privileges



To generate DDL for database objects:

  1. Open the Generate DDL window.

  2. Optional. Either accept the default or select a different value for Schema. Selecting the value All Schemas will generate DDL for all schemas in the database.

  3. Optional. Select or clear the Database objects check box to indicate whether to generate DDL statements for Database objects such as tables, views and indexes.

  4. Optional. Select or clear the Tablespaces, nodegroups, and bufferpools check box to indicate whether to generate DDL statements for these objects.

  5. Optional. Select or clear the Authorization statements check box to indicate whether to generate SQL authorization statements (GRANT) for database objects.

  6. Optional. Select the Database statistics check box if you want to generate SQL statements for table statistics in the database.

  7. Optional. Select the Update statistics check box if you want to generate an update statistics command.

  8. Optional. Select Include COMMIT statements after every table check box if you want to include COMMIT statements after every table.

  9. Optional. To schedule the job that will generate DDL, click Schedule. The Schedule window opens.

  10. Optional. To view and save the SQL command that will generate the DDL, click Show Command. The Show Command window opens.

  11. To generate DDL, click Generate. The Run Script window opens. Type a userid and password and click OK. A job is created with the contents of the db2look command. A DB2 Message window appears with the job id of the new job. The job creates a script generated by the db2look command. Click OK to close the message window.

  12. Use the Job History page of the Journal notebook to view the results of this job, and to view the contents of a saved script associated with the job. Click mouse button 2 on the job and select Show results from the pop-up menu. The Job Results window opens. The output of the db2look command is shown in the Job output pane. The User comment pane identifies where the output file is saved. Select Create Script to create a script of the results. The New Command Script window appears.


Related information